github.com/neohugo/neohugo@v0.123.8/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      {{- $name := .Name }}
    31      {{- with .Identifier }}
    32        {{- with T . }}
    33          {{- $name = . }}
    34        {{- end }}
    35      {{- end }}
    36      <li>
    37        <a
    38          {{- range $k, $v := $attrs }}
    39            {{- with $v }}
    40              {{- printf " %s=%q" $k $v | safeHTMLAttr }}
    41            {{- end }}
    42          {{- end -}}
    43        >{{ $name }}</a>
    44        {{- with .Children }}
    45          <ul>
    46            {{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" .) }}
    47          </ul>
    48        {{- end }}
    49      </li>
    50    {{- end }}
    51  {{- end }}