taxonomies - add active class

This commit is contained in:
James Ray 2021-08-15 11:33:55 -04:00
parent f420e5763c
commit 47906d8f84

View file

@ -1,11 +1,15 @@
{{ $context := .context }}
{{ $taxo := .taxo }}
{{ $title := .title }}
{{ $class:= "" }}
{{ if isset $context.Site.Taxonomies ( lower $taxo ) }}
{{ $taxonomy := index $context.Site.Taxonomies ( lower $taxo ) }}
{{ if (gt (len $taxonomy) 0)}}
{{ range $taxonomy }}
<li><a class="taxonomy-term" href="{{ .Page.Permalink }}" data-taxonomy-term="{{ urlize .Page.Title }}"><span class="taxonomy-label">{{ .Page.Title }}</span></a></li>
{{if eq $context.Title .Page.Title}}
{{ $class = "active" }}
{{end}}
<li><a class="taxonomy-term {{ $class }}" href="{{ .Page.Permalink }}" data-taxonomy-term="{{ urlize .Page.Title }}"><span class="taxonomy-label">{{ .Page.Title }}</span></a></li>
{{ end }}
{{ end }}
{{ end }}