Format template

master
Will Faught 2 years ago
parent a576468b7e
commit eb573283fb

@ -1,15 +1,16 @@
{{ $p := . }} {{ $basepath := path.Clean (urls.Parse .Site.BaseURL).Path }}
{{ $basePath := path.Clean (urls.Parse .Site.BaseURL).Path }}
{{ if eq $basePath "/" }}
{{ $basePath = "" }}
{{ end }}
{{ $links := false }} {{ $links := false }}
{{ $pills := false }} {{ $pills := false }}
{{ $tabs := false }} {{ $tabs := false }}
{{ if eq $basepath "/" }}
{{ $basepath = "" }}
{{ end }}
{{ with .Site.Params.paige.menu_style }} {{ with .Site.Params.paige.menu_style }}
{{ if eq . `links` }} {{ if eq . "links" }}
{{ $links = true }} {{ $links = true }}
{{ else if eq . `tabs` }} {{ else if eq . "tabs" }}
{{ $tabs = true }} {{ $tabs = true }}
{{ else }} {{ else }}
{{ $pills = true }} {{ $pills = true }}
@ -17,10 +18,11 @@
{{ else }} {{ else }}
{{ $pills = true }} {{ $pills = true }}
{{ end }} {{ end }}
<nav class="justify-content-center my-3 nav {{ if $pills }} nav-pills {{ else if $tabs }} nav-tabs {{ end }}"> <nav class="justify-content-center my-3 nav {{ if $pills }} nav-pills {{ else if $tabs }} nav-tabs {{ end }}">
{{ range .Site.Menus.main }} {{ range .Site.Menus.main }}
{{ $pagePath := strings.TrimPrefix $basePath $p.RelPermalink }} {{ $pagePath := strings.TrimPrefix $basepath $.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 {{ if $active }} aria-current="page" {{ end }} class="{{ if $active }} active {{ if $links }} link-secondary {{ end }} {{ end }} nav-link" href="{{ .URL }}">{{ .Name }}</a> <a {{ if $active }} aria-current="page" {{ end }} class="{{ if $active }} active {{ if $links }} link-secondary {{ end }} {{ end }} nav-link" href="{{ .URL }}">{{ .Name }}</a>
{{ end }} {{ end }}

Loading…
Cancel
Save