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