package nav import ( "context" "git.haelnorr.com/h/oslstats/internal/db" "git.haelnorr.com/h/oslstats/pkg/contexts" ) type ProfileItem struct { name string // Label to display href string // Link reference } // Return the list of profile links func getProfileItems(ctx context.Context) []ProfileItem { items := []ProfileItem{ { name: "Profile", href: "/profile", }, { name: "Account", href: "/account", }, } // Add admin link if user has admin role cache := contexts.Permissions(ctx) if cache != nil && cache.Roles["admin"] { items = append(items, ProfileItem{ name: "Admin Panel", href: "/admin", }) } return items } // Returns the right portion of the navbar templ navRight() { {{ user := db.CurrentUser(ctx) }} {{ items := getProfileItems(ctx) }}