From 6c02e3fe90815e3830392aca1d5c2700b6c32f41 Mon Sep 17 00:00:00 2001 From: Haelnorr Date: Thu, 13 Feb 2025 23:14:44 +1100 Subject: [PATCH] Added username to navbar when logged in --- db/connection.go | 3 ++- view/component/nav/navbarright.templ | 37 +++++++++++++++++++--------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/db/connection.go b/db/connection.go index 88c2075..d1415c5 100644 --- a/db/connection.go +++ b/db/connection.go @@ -4,8 +4,9 @@ import ( "database/sql" "fmt" - _ "github.com/mattn/go-sqlite3" "github.com/pkg/errors" + + _ "github.com/mattn/go-sqlite3" ) // Returns a database connection handle for the Turso DB diff --git a/view/component/nav/navbarright.templ b/view/component/nav/navbarright.templ index aea6e7d..41110c7 100644 --- a/view/component/nav/navbarright.templ +++ b/view/component/nav/navbarright.templ @@ -1,23 +1,36 @@ package nav +import "projectreshoot/contexts" + // Returns the right portion of the navbar templ navRight() { + {{ user := contexts.GetUser(ctx) }}
- + } else { + - + + href="/register" + > + Register + + }