diff --git a/layouts/partials/categories_menu.html b/layouts/partials/categories_menu.html index 4b2770d1820763966cd4d507ff880ac588bb3485..538b918308f041901b31b95ff2bc028491866987 100644 --- a/layouts/partials/categories_menu.html +++ b/layouts/partials/categories_menu.html @@ -6,19 +6,18 @@ <!-- {{ $taxonomy := .Data.Plural }} --> {{ $taxonomy := "tags" }} {{/* Get sections where one or more pages has one or more terms in the current taxonomy. */}} - {{ $sections := slice }} + {{ $terms := slice }} {{ range $term, $weightedPages := index site.Taxonomies $taxonomy }} - {{ range $weightedPages }} - {{ $sections = $sections | append .CurrentSection | uniq | sort }} + {{ range $weightedPage := $weightedPages }} + {{ if (eq $hereSection $weightedPage.Section) }} + {{ $terms = $terms | append $term | uniq }} + {{ end }} {{ end }} {{ end }} + {{/* List pages by term by section. */}} - {{ range $section := (where $sections ".Path" $hereSection) }} - {{ range $term, $weightedPages := index site.Taxonomies $taxonomy }} - {{ $termPage := site.GetPage path.Join $taxonomy $term }} - {{ with where $weightedPages "Section" $section.Path }} - <a href="{{ $termPage.RelPermalink }}" class='menu-item' data-slug='{{ $termPage.LinkTitle }}' title="All pages with tag <i>{{ $termPage.LinkTitle }}</i>">{{ $termPage.LinkTitle }}</a> - {{ end }} - {{ end }} + {{ range $term := $terms }} + {{ $termPage := site.GetPage path.Join $taxonomy $term }} + <a href="{{ $termPage.RelPermalink }}" class='menu-item' data-slug='{{ $termPage.LinkTitle }}' title="All pages with tag <i>{{ $termPage.LinkTitle }}</i>">{{ $termPage.LinkTitle }}</a> {{ end }} </nav>