Added username to navbar when logged in

This commit is contained in:
2025-02-13 23:14:44 +11:00
parent 15c2dcc46f
commit 6c02e3fe90
2 changed files with 27 additions and 13 deletions

View File

@@ -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

View File

@@ -1,9 +1,21 @@
package nav
import "projectreshoot/contexts"
// Returns the right portion of the navbar
templ navRight() {
{{ user := contexts.GetUser(ctx) }}
<div class="flex items-center gap-2">
<div class="sm:flex sm:gap-2">
if user != nil {
<a
class="hidden rounded-lg px-4 py-2 sm:block
bg-sapphire hover:bg-sapphire/75 text-mantle transition"
href="#"
>
{ user.Username }
</a>
} else {
<a
class="hidden rounded-lg px-4 py-2 sm:block
bg-green hover:bg-green/75 text-mantle transition"
@@ -18,6 +30,7 @@ templ navRight() {
>
Register
</a>
}
</div>
<button
@click="open = !open"