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.

30 lines
1.0 KiB
HTML

{{ $basepath := path.Clean (urls.Parse .Site.BaseURL).Path }}
{{ $links := false }}
{{ $pills := false }}
{{ $tabs := false }}
{{ if eq $basepath "/" }}
{{ $basepath = "" }}
{{ end }}
{{ with .Site.Params.paige.menu_style }}
{{ if eq . "links" }}
{{ $links = true }}
{{ else if eq . "tabs" }}
{{ $tabs = true }}
{{ else }}
{{ $pills = true }}
{{ end }}
{{ else }}
{{ $pills = true }}
{{ end }}
<nav class="justify-content-center my-3 nav {{ if $pills }} nav-pills {{ else if $tabs }} nav-tabs {{ end }}">
{{ range .Site.Menus.main }}
{{ $pagePath := strings.TrimPrefix $basepath $.RelPermalink }}
{{ $menuPath := strings.TrimPrefix $basepath .URL }}
{{ $active := or (and (eq $menuPath `/`) (eq $pagePath `/`)) (and (ne $menuPath `/`) (hasPrefix $pagePath $menuPath)) }}
<a {{ if $active }} aria-current="page" {{ end }} class="{{ if $active }} active {{ if $links }} link-secondary {{ end }} {{ end }} nav-link" href="{{ .URL }}">{{ .Name }}</a>
{{ end }}
</nav>