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">
<ul class="justify-content-center nav nav-pills">
{{ $p := . }} {{ $p := . }}
{{ $basePath := path.Clean (urls.Parse .Site.BaseURL).Path }} {{ $basePath := path.Clean (urls.Parse .Site.BaseURL).Path }}
{{ if eq $basePath "/" }} {{ if eq $basePath "/" }}
{{ $basePath = "" }} {{ $basePath = "" }}
{{ end }} {{ end }}
<nav class="justify-content-center nav nav-pills py-3">
{{ 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)) }}
<li class="nav-item"><a href="{{ .URL }}" class="nav-link{{if $active }} active{{ end }}">{{ .Name }}</a></li> <a href="{{ .URL }}" class="nav-link{{ if $active }} active{{ end }}"{{ if $active }} aria-current="page"{{ end }}>{{ .Name }}</a>
{{ end }} {{ end }}
</ul>
</nav> </nav>

Loading…
Cancel
Save