From 69035f8d09863d3bf57dea4cd951becf83a574b7 Mon Sep 17 00:00:00 2001 From: geekifan Date: Wed, 23 Apr 2025 11:31:00 +0800 Subject: [PATCH] update topbar --- layouts/partials/topbar.html | 63 ++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 25 deletions(-) diff --git a/layouts/partials/topbar.html b/layouts/partials/topbar.html index 8572396..0ba5a58 100644 --- a/layouts/partials/topbar.html +++ b/layouts/partials/topbar.html @@ -5,35 +5,48 @@ {{ $page := . }} {{ $url := .RelPermalink }} {{ $paths := split (trim $url "/") "/" }} + {{ $is_home := or (eq $url "/") (eq $url (relLangURL "/")) }} - {{ if or (eq $url "/") (eq $url (relLangURL "/")) }} + {{ if $is_home }} {{ T "tabs.home" | title }} - {{ else }} - {{ range $index, $item := $paths }} - {{ if eq $index 0 }} - - - {{- T "tabs.home" | title -}} - - - - {{ $currentMenuEntry := "" }} - {{ range site.Menus.main }} - {{ if eq .URL $page.RelPermalink }} - {{ $currentMenuEntry = . }} - {{ end }} - {{ end }} - - - {{ if $currentMenuEntry }} - {{ $currentMenuEntry.Name }} - {{ else }} - {{ $page.Title }} - {{ end }} - - + {{else}} + + + {{- T "tabs.home" | title -}} + + + {{ if eq $page.Type "tags" }} + {{ if .Data.Term}} + {{i18n "tabs.tags"}} + {{ .Data.Term }} + {{ else }} + {{i18n "tabs.tags"}} {{ end }} + {{ else if eq $page.Type "categories" }} + {{ if .Data.Term}} + {{i18n "tabs.categories"}} + {{ .Data.Term }} + {{ else }} + {{i18n "tabs.categories"}} + {{ end }} + {{ else }} + + {{ $currentMenuEntry := "" }} + {{ range site.Menus.main }} + {{ if eq .URL $page.RelPermalink }} + {{ $currentMenuEntry = . }} + {{ end }} + {{ end }} + + + {{ if $currentMenuEntry }} + {{ $currentMenuEntry.Name }} + {{ else }} + {{ $page.Title }} + {{ end }} + + {{ end }} {{ end }}