github.com/anakojm/hugo-katex@v0.0.0-20231023141351-42d6f5de9c0b/create/skeletons/theme/layouts/partials/menu.html (about) 1 {{- /* 2 Renders a menu for the given menu ID. 3 4 @context {page} page The current page. 5 @context {string} menuID The menu ID. 6 7 @example: {{ partial "menu.html" (dict "menuID" "main" "page" .) }} 8 */}} 9 10 {{- $page := .page }} 11 {{- $menuID := .menuID }} 12 13 {{- with index site.Menus $menuID }} 14 <nav> 15 <ul> 16 {{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" .) }} 17 </ul> 18 </nav> 19 {{- end }} 20 21 {{- define "partials/inline/menu/walk.html" }} 22 {{- $page := .page }} 23 {{- range .menuEntries }} 24 {{- $attrs := dict "href" .URL }} 25 {{- if $page.IsMenuCurrent .Menu . }} 26 {{- $attrs = merge $attrs (dict "class" "active" "aria-current" "page") }} 27 {{- else if $page.HasMenuCurrent .Menu .}} 28 {{- $attrs = merge $attrs (dict "class" "ancestor" "aria-current" "true") }} 29 {{- end }} 30 <li> 31 <a 32 {{- range $k, $v := $attrs }} 33 {{- with $v }} 34 {{- printf " %s=%q" $k $v | safeHTMLAttr }} 35 {{- end }} 36 {{- end -}} 37 >{{ or (T .Identifier) .Name | safeHTML }}</a> 38 {{- with .Children }} 39 <ul> 40 {{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" .) }} 41 </ul> 42 {{- end }} 43 </li> 44 {{- end }} 45 {{- end }}