2023-12-08 10:56:22 +01:00
|
|
|
{{- /*
|
|
|
|
Renders a menu for the given menu ID.
|
|
|
|
|
|
|
|
@context {page} page The current page.
|
|
|
|
@context {string} menuID The menu ID.
|
|
|
|
|
|
|
|
@example: {{ partial "menu.html" (dict "menuID" "main" "page" .) }}
|
|
|
|
*/}}
|
|
|
|
|
|
|
|
{{- $page := .page }}
|
|
|
|
{{- $menuID := .menuID }}
|
|
|
|
|
|
|
|
{{- with index site.Menus $menuID }}
|
2023-12-08 13:43:16 +01:00
|
|
|
<nav class="navbar navbar-expand-md navbar-dark bg-dark mb-4">
|
|
|
|
<div class="container-fluid">
|
2023-12-08 14:43:50 +01:00
|
|
|
{{ partial "header/brand.html" . }}
|
2023-12-08 13:43:16 +01:00
|
|
|
<button
|
|
|
|
class="navbar-toggler" type="button" data-bs-toggle="collapse"
|
|
|
|
data-bs-target="#navbarCollapse" aria-controls="navbarCollapse"
|
|
|
|
aria-expanded="false" aria-label="Toggle navigation"
|
|
|
|
>
|
|
|
|
<span class="navbar-toggler-icon"></span>
|
|
|
|
</button>
|
|
|
|
<div class="collapse navbar-collapse" id="navbarCollapse">
|
2023-12-08 13:51:07 +01:00
|
|
|
<ul class="navbar-nav me-auto mb-2 mb-md-0">
|
2023-12-08 13:43:16 +01:00
|
|
|
{{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" .) }}
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-12-08 10:56:22 +01:00
|
|
|
</nav>
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{- define "partials/inline/menu/walk.html" }}
|
|
|
|
{{- $page := .page }}
|
|
|
|
{{- range .menuEntries }}
|
|
|
|
{{- $attrs := dict "href" .URL }}
|
|
|
|
{{- if $page.IsMenuCurrent .Menu . }}
|
|
|
|
{{- $attrs = merge $attrs (dict "class" "active" "aria-current" "page") }}
|
|
|
|
{{- else if $page.HasMenuCurrent .Menu .}}
|
|
|
|
{{- $attrs = merge $attrs (dict "class" "ancestor" "aria-current" "true") }}
|
|
|
|
{{- end }}
|
2023-12-09 19:52:32 +01:00
|
|
|
{{- with .Params.blankTarget }}
|
|
|
|
{{- $attrs = merge $attrs (dict "target" "_blank") }}
|
|
|
|
{{- end }}
|
2023-12-08 13:43:16 +01:00
|
|
|
<li class="nav-item">
|
|
|
|
<a class="nav-link" aria-current="page"
|
2023-12-08 10:56:22 +01:00
|
|
|
{{- range $k, $v := $attrs }}
|
|
|
|
{{- with $v }}
|
|
|
|
{{- printf " %s=%q" $k $v | safeHTMLAttr }}
|
|
|
|
{{- end }}
|
|
|
|
{{- end -}}
|
|
|
|
>{{ or (T .Identifier) .Name | safeHTML }}</a>
|
|
|
|
{{- with .Children }}
|
|
|
|
<ul>
|
|
|
|
{{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" .) }}
|
|
|
|
</ul>
|
|
|
|
{{- end }}
|
|
|
|
</li>
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|