menu.html (937B)
1 {{- $page := .page -}} 2 {{- $menuID := .menuID -}} 3 {{- with index site.Menus $menuID -}} 4 {{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" .) -}} 5 {{- end -}} 6 {{- define "_partials/inline/menu/walk.html" -}} 7 {{- $page := .page -}} 8 {{- range .menuEntries -}} 9 {{- $attrs := dict "href" .URL -}} 10 {{- if $page.IsMenuCurrent .Menu . -}} 11 {{- $attrs = merge $attrs (dict "class" "active" "aria-current" "page") -}} 12 {{- else if $page.HasMenuCurrent .Menu . -}} 13 {{- $attrs = merge $attrs (dict "class" "ancestor" "aria-current" "true") -}} 14 {{- end -}} 15 {{- $name := .Name -}} 16 {{- with .Identifier -}} 17 {{- with T . -}} 18 {{- $name = . -}} 19 {{- end -}} 20 {{- end -}} 21 <a 22 {{- range $k, $v := $attrs -}} 23 {{- with $v -}} 24 {{- printf " %s=%q" $k $v | safeHTMLAttr -}} 25 {{- end -}} 26 {{- end -}} 27 >{{ $name }}</a> 28 {{ with .Children -}} 29 {{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" .) -}} 30 {{- end -}} 31 {{- end -}} 32 {{- end -}}