Simplify menu

master
Will Faught 3 years ago
parent 613b2f5767
commit 5185a619d8

@ -34,6 +34,7 @@ Term page:
## Features ## Features
- Accessibility support
- Blog - Blog
- Bootstrap support - Bootstrap support
- Facebook sharing support - Facebook sharing support

@ -1,15 +1,13 @@
<nav class="d-flex justify-content-center py-3"> {{ $p := . }}
<ul class="justify-content-center nav nav-pills"> {{ $basePath := path.Clean (urls.Parse .Site.BaseURL).Path }}
{{ $p := . }} {{ if eq $basePath "/" }}
{{ $basePath := path.Clean (urls.Parse .Site.BaseURL).Path }} {{ $basePath = "" }}
{{ if eq $basePath "/" }} {{ end }}
{{ $basePath = "" }} <nav class="justify-content-center nav nav-pills py-3">
{{ end }} {{ range .Site.Menus.main }}
{{ range .Site.Menus.main }} {{ $pagePath := strings.TrimPrefix $basePath $p.RelPermalink }}
{{ $pagePath := strings.TrimPrefix $basePath $p.RelPermalink }} {{ $menuPath := strings.TrimPrefix $basePath .URL }}
{{ $menuPath := strings.TrimPrefix $basePath .URL }} {{ $active := or (and (eq $menuPath `/`) (eq $pagePath `/`)) (and (ne $menuPath `/`) (hasPrefix $pagePath $menuPath)) }}
{{ $active := or (and (eq $menuPath `/`) (eq $pagePath `/`)) (and (ne $menuPath `/`) (hasPrefix $pagePath $menuPath)) }} <a href="{{ .URL }}" class="nav-link{{ if $active }} active{{ end }}"{{ if $active }} aria-current="page"{{ end }}>{{ .Name }}</a>
<li class="nav-item"><a href="{{ .URL }}" class="nav-link{{if $active }} active{{ end }}">{{ .Name }}</a></li> {{ end }}
{{ end }}
</ul>
</nav> </nav>

Loading…
Cancel
Save