{{- $kind := .kind -}} {{ $items := .items }} {{ $context := .context }} {{ if $kind }} {{ $menu := partial "GetMenu" $kind }} {{ $items = $menu.items }} {{ end }} {{- $level := .level -}} {{- $stop := .stop -}} {{- $dropdown := .dropdown }} {{- $ulClass := "" -}} {{- if .class -}} {{- $ulClass = printf "%s " .class -}} {{- end -}} {{ $extern_link := i18n "commons.link.blank" }} <ul class="{{ $ulClass }}{{ if $level }}nav-level-{{ $level }}{{ end }}"> {{ range $items -}} {{- $slug := urlize .title -}} {{- $itemClass := "" -}} {{- $linkClass := "" -}} {{- $attr := "" -}} {{- $attr_title := "" -}} {{- $hasDropdown := false -}} {{ if eq $context.RelPermalink .target }} {{ $linkClass = "active" }} {{ end }} {{- if gt (len .children) 0 -}} {{- $itemClass = printf "%shas-children" $itemClass -}} {{- end -}} {{- if and (gt (len .children) 0) $dropdown (eq $level 1) -}} {{- $hasDropdown = true -}} {{- $attr = printf "id=\"dropdown-%s\" role=\"button\" aria-expanded=\"false\" tabindex=\"0\"" $slug -}} {{- end -}} {{- if and (hasPrefix .target "http") (eq .kind "url") -}} {{- $attr = " target=\"_blank\" rel=\"noreferrer\"" -}} {{- $attr_title = printf "title=\"%s - %s\"" .title $extern_link -}} {{- end -}} {{- if or (ne $stop 1) (and (eq $stop 1) (ne .kind "blank")) -}} <li{{ if ne $itemClass ""}} class="{{ $itemClass }}"{{ end }}> {{- if ne .kind "blank" -}} <a href="{{ .target }}"{{ if ne $linkClass ""}} class="{{ $linkClass }}"{{ end }} {{ safeHTMLAttr $attr }} {{ safeHTMLAttr $attr_title }}>{{ .title }}</a> {{- else -}} <span class="{{ if ne $linkClass ""}} {{ $linkClass }}{{ end }}{{ if gt .level 1 }} disabled{{ end }}" {{ safeHTMLAttr $attr }}>{{ .title }}</span> {{- end -}} {{- if ne $stop $level -}} {{- if $hasDropdown }} <div class="dropdown-menu" aria-labelledby="dropdown-{{ $slug }}"> {{- end -}} {{- if gt (len .children) 0 -}} {{- $nextLevel := add $level 1 -}} {{- partial "commons/menu.html" (dict "items" .children "level" $nextLevel "context" $context ) -}} {{- end -}} {{- if $hasDropdown -}} </div> {{- end -}} {{- end -}} </li> {{- end -}} {{ end -}} </ul>