You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
2.0 KiB
HTML

{{ $page := . }}
{{ $basepath := path.Clean (urls.Parse site.BaseURL).Path }}
{{ $breakpoint := $page.Param "paige.menu.breakpoint" | default "sm" }}
{{ $pills := false }}
{{ $underline := false }}
{{ if eq $basepath "/" }}
{{ $basepath = "" }}
{{ end }}
{{ $pagepath := strings.TrimPrefix $basepath $page.RelPermalink }}
{{ with $page.Param "paige.menu.style" }}
{{ if eq . "pills" }}
{{ $pills = true }}
{{ else if eq . "underline" }}
{{ $underline = true }}
{{ else if ne . "links" }}
{{ errorf "paige/menu: invalid menu style: %q" . }}
{{ end }}
{{ else }}
{{ $pills = true }}
{{ end }}
{{ with site.Menus.main }}
<nav class="justify-content-center navbar navbar-expand-{{ $breakpoint }}" id="paige-menu">
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#paige-menu-toggler" aria-controls="paige-menu-toggler" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse justify-content-center mt-3 mt-{{ $breakpoint }}-0 navbar-collapse" id="paige-menu-toggler">
<div class="align-items-center flex-column flex-{{ $breakpoint }}-row justify-content-center nav {{ if $pills }} nav-pills {{ else if $underline }} nav-underline {{ end }}">
{{ range . }}
{{ $menupath := strings.TrimPrefix $basepath .URL }}
{{ $home := (and (eq $menupath "/") (eq $pagepath "/")) }}
{{ $menuprefix := (and (ne $menupath "/") (hasPrefix $pagepath $menupath)) }}
{{ $sectionprefix := (and (ne $menupath "/") (hasPrefix $menupath (printf "/%s/" $page.Section))) }}
{{ $active := or $home $menuprefix $sectionprefix }}
<a {{ if $active }} aria-current="page" {{ end }} class="{{ if $active }} active {{ end }} nav-link" href="{{ .URL | safeURL }}">{{ .Name }}</a>
{{ end }}
</div>
</div>
</nav>
{{ end }}