Skip to content

Commit e10b3ae

Browse files
authored
fix: don't display hamburger menu when there are no menus defined (#39)
1 parent a408abf commit e10b3ae

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

layouts/partials/menu.html

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
{{- $page := .page -}}
22
{{- $menuID := .menuID -}}
3-
{{- with index site.Menus $menuID -}}
3+
{{- $menu := index site.Menus $menuID -}}
4+
{{- $hasValidEntries := false -}}
5+
{{- range $menu -}}
6+
{{- if and .Name .URL -}}
7+
{{- $hasValidEntries = true -}}
8+
{{- break -}}
9+
{{- end -}}
10+
{{- end -}}
11+
{{- if $hasValidEntries -}}
412
<nav class="flex flex-1 flex-row-reverse">
513
<label for="menu" tabindex="0">
614
<span class="fa-stack">
@@ -10,7 +18,7 @@
1018
</label>
1119
<input id="menu" type="checkbox" />
1220
<ul class="md:flex m-0 p-0 md:pr-4">
13-
{{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" .) -}}
21+
{{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" $menu) -}}
1422
</ul>
1523
</nav>
1624
{{- end -}}
@@ -40,5 +48,4 @@
4048
</li>
4149
{{- end -}}
4250
{{- end -}}
43-
4451
{{- /* Trim EOF */ -}}

0 commit comments

Comments
 (0)