Indent template logic

This commit is contained in:
Will Faught
2023-01-07 09:04:54 -08:00
parent 9848a64ff3
commit 994591f932
17 changed files with 340 additions and 340 deletions

View File

@@ -1,27 +1,27 @@
{{ $p := . }}
{{ $basePath := path.Clean (urls.Parse .Site.BaseURL).Path }}
{{ if eq $basePath "/" }}
{{ $basePath = "" }}
{{ $basePath = "" }}
{{ end }}
{{ $links := false }}
{{ $pills := false }}
{{ $tabs := false }}
{{ with .Site.Params.paige.menu_style }}
{{ if eq . `links` }}
{{ $links = true }}
{{ else if eq . `tabs` }}
{{ $tabs = true }}
{{ if eq . `links` }}
{{ $links = true }}
{{ else if eq . `tabs` }}
{{ $tabs = true }}
{{ else }}
{{ $pills = true }}
{{ end }}
{{ else }}
{{ $pills = true }}
{{ end }}
{{ else }}
{{ $pills = true }}
{{ $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 $p.RelPermalink }}
{{ $menuPath := strings.TrimPrefix $basePath .URL }}
{{ $active := or (and (eq $menuPath `/`) (eq $pagePath `/`)) (and (ne $menuPath `/`) (hasPrefix $pagePath $menuPath)) }}
<a href="{{ .URL }}" class="{{ if $active }}active {{ if $links }}link-secondary {{ end }}{{ end }}nav-link"{{ if $active }} aria-current="page"{{ end }}>{{ .Name }}</a>
{{ $pagePath := strings.TrimPrefix $basePath $p.RelPermalink }}
{{ $menuPath := strings.TrimPrefix $basePath .URL }}
{{ $active := or (and (eq $menuPath `/`) (eq $pagePath `/`)) (and (ne $menuPath `/`) (hasPrefix $pagePath $menuPath)) }}
<a href="{{ .URL }}" class="{{ if $active }}active {{ if $links }}link-secondary {{ end }}{{ end }}nav-link"{{ if $active }} aria-current="page"{{ end }}>{{ .Name }}</a>
{{ end }}
</nav>