summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hugo.toml5
-rw-r--r--layouts/_partials/header.html2
-rw-r--r--layouts/_partials/menu.html54
3 files changed, 11 insertions, 50 deletions
diff --git a/hugo.toml b/hugo.toml
index d6ffac2..fbef7d4 100644
--- a/hugo.toml
+++ b/hugo.toml
@@ -3,3 +3,8 @@ languageCode = 'zh-cn'
title = 'Jar'
mainSections = ['notes']
+
+[params]
+ [[params.nav]]
+ name = '瓶口'
+ link = '/'
diff --git a/layouts/_partials/header.html b/layouts/_partials/header.html
index f88077f..b3d9f1d 100644
--- a/layouts/_partials/header.html
+++ b/layouts/_partials/header.html
@@ -1,5 +1,5 @@
<div class="text-center font-mono">
<img src="/favicon.png" class="dark:invert" style="width: 200px">
<h1 class="text-base">{{ site.Title }}.png</h1>
- {{ partial "menu.html" (dict "menuID" "main" "page" .) }}
+ {{ partial "menu.html" . }}
</div>
diff --git a/layouts/_partials/menu.html b/layouts/_partials/menu.html
index ab36f0c..7e9fccd 100644
--- a/layouts/_partials/menu.html
+++ b/layouts/_partials/menu.html
@@ -1,51 +1,7 @@
-{{- /*
-Renders a menu for the given menu ID.
-
-@context {page} page The current page.
-@context {string} menuID The menu ID.
-
-@example: {{ partial "menu.html" (dict "menuID" "main" "page" .) }}
-*/}}
-
-{{- $page := .page }}
-{{- $menuID := .menuID }}
-
-{{- with index site.Menus $menuID }}
- <nav>
+<nav>
<ul class="list-none m-0 p-0">
- {{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" .) }}
+ {{ range .Site.Params.nav }}
+ <li><a href="{{ .link }}">{{ .name }}</a></li>
+ {{ end }}
</ul>
- </nav>
-{{- end }}
-
-{{- define "_partials/inline/menu/walk.html" }}
- {{- $page := .page }}
- {{- range .menuEntries }}
- {{- $attrs := dict "href" .URL }}
- {{- if $page.IsMenuCurrent .Menu . }}
- {{- $attrs = merge $attrs (dict "class" "active" "aria-current" "page") }}
- {{- else if $page.HasMenuCurrent .Menu .}}
- {{- $attrs = merge $attrs (dict "class" "ancestor" "aria-current" "true") }}
- {{- end }}
- {{- $name := .Name }}
- {{- with .Identifier }}
- {{- with T . }}
- {{- $name = . }}
- {{- end }}
- {{- end }}
- <li class="list-none">
- <a
- {{- range $k, $v := $attrs }}
- {{- with $v }}
- {{- printf " %s=%q" $k $v | safeHTMLAttr }}
- {{- end }}
- {{- end -}}
- >{{ $name }}</a>
- {{- with .Children }}
- <ul>
- {{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" .) }}
- </ul>
- {{- end }}
- </li>
- {{- end }}
-{{- end }}
+</nav>