Simplify menu
parent
613b2f5767
commit
5185a619d8
@ -1,15 +1,13 @@
|
||||
<nav class="d-flex justify-content-center py-3">
|
||||
<ul class="justify-content-center nav nav-pills">
|
||||
{{ $p := . }}
|
||||
{{ $basePath := path.Clean (urls.Parse .Site.BaseURL).Path }}
|
||||
{{ if eq $basePath "/" }}
|
||||
{{ $basePath = "" }}
|
||||
{{ end }}
|
||||
<nav class="justify-content-center nav nav-pills py-3">
|
||||
{{ range .Site.Menus.main }}
|
||||
{{ $pagePath := strings.TrimPrefix $basePath $p.RelPermalink }}
|
||||
{{ $menuPath := strings.TrimPrefix $basePath .URL }}
|
||||
{{ $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 }}
|
||||
</ul>
|
||||
</nav>
|
||||
|
Loading…
Reference in New Issue