From e0768c2aacd72bd4e62d0847dc2231644664d08d Mon Sep 17 00:00:00 2001 From: grm Date: Sat, 12 Sep 2026 12:16:05 +0300 Subject: Highlight the current tab in the dashboard nav Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01Sd8UPWrvyYCLj97JexNw3A --- internal/web/static/dashboard.css | 2 ++ internal/web/templates.go | 2 ++ internal/web/templates/partials/dashnav.html | 19 +++++++++++-------- 3 files changed, 15 insertions(+), 8 deletions(-) (limited to 'internal') diff --git a/internal/web/static/dashboard.css b/internal/web/static/dashboard.css index 48f9eff..455daec 100644 --- a/internal/web/static/dashboard.css +++ b/internal/web/static/dashboard.css @@ -22,6 +22,8 @@ code { background: #eef; padding: 0 0.25em; border-radius: 3px; font-size: 0.95e .blogbar .topbar-inner { padding: 0.5em 1em; } .blogbar a { display: inline-block; padding: 0.3em 0.6em; text-decoration: none; color: #333; border-radius: 4px; } .blogbar a:hover { background: #eef1f5; } +.blogbar a.active { background: #1f2933; color: #fff; } +.topbar .links a.active { text-decoration: underline; } .blogbar .blogname { margin-right: 0.6em; } .blogbar .view { float: right; color: #1a5fb4; font-weight: bold; } diff --git a/internal/web/templates.go b/internal/web/templates.go index f322ccc..1e17654 100644 --- a/internal/web/templates.go +++ b/internal/web/templates.go @@ -99,6 +99,8 @@ var funcs = template.FuncMap{ return *p }, "lower": strings.ToLower, + // hasPrefix marks the current dashboard tab: {{if hasPrefix .Path "/b/x/posts"}} + "hasPrefix": strings.HasPrefix, // dict builds a map for passing several values to a partial: {{template "x" (dict "a" 1 "b" 2)}} "dict": func(kv ...any) (map[string]any, error) { if len(kv)%2 != 0 { diff --git a/internal/web/templates/partials/dashnav.html b/internal/web/templates/partials/dashnav.html index 13a04d0..44e518e 100644 --- a/internal/web/templates/partials/dashnav.html +++ b/internal/web/templates/partials/dashnav.html @@ -4,23 +4,26 @@ {{if .User}} {{.User.Username}}{{if .User.IsSuperadmin}} (superadmin){{end}} - {{if .User.IsSuperadmin}}Admin{{end}} - Password + {{if .User.IsSuperadmin}}Admin{{end}} + Password
{{end}} {{if .Blog}} +{{$b := printf "/b/%s/" .Blog.Subdomain}} -- cgit v1.2.3