Fix multiple active menu in taxonomy

Signed-off-by: hossainemruz <hossainemruz@gmail.com>
This commit is contained in:
hossainemruz 2021-08-16 23:23:18 +06:00
parent 7b92452e2b
commit b68fd7a504

View file

@ -1,6 +1,5 @@
{{ $context := .context }} {{ $context := .context }}
{{ $taxo := .taxo }} {{ $taxo := .taxo }}
{{ $title := .title }}
{{ $class:= "" }} {{ $class:= "" }}
{{ if isset $context.Site.Taxonomies ( lower $taxo ) }} {{ if isset $context.Site.Taxonomies ( lower $taxo ) }}
{{ $taxonomy := index $context.Site.Taxonomies ( lower $taxo ) }} {{ $taxonomy := index $context.Site.Taxonomies ( lower $taxo ) }}
@ -8,6 +7,8 @@
{{ range $taxonomy }} {{ range $taxonomy }}
{{if eq $context.Title .Page.Title}} {{if eq $context.Title .Page.Title}}
{{ $class = "active" }} {{ $class = "active" }}
{{else}}
{{$class = ""}}
{{end}} {{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> <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 }}