Use singular or plural taxonomy names depending on how many items are in the taxonomy for the page

This commit is contained in:
Eryn Wells 2024-08-02 15:47:33 -07:00
parent 1b463e35d8
commit 97aa739b3f
3 changed files with 17 additions and 10 deletions

View file

@ -1,2 +1,2 @@
{{ partial "page/taxonomy_list.html" (dict "page" . "term" "categories") }}
{{ partial "page/taxonomy_list.html" (dict "page" . "term" "tags") }}
{{ partial "page/taxonomy_list.html" (dict "page" . "taxonomy" "categories") }}
{{ partial "page/taxonomy_list.html" (dict "page" . "taxonomy" "tags") }}

View file

@ -1,6 +1,17 @@
{{- $terms := .page.GetTerms .term -}}
{{ with $terms }}
<ul class="taxonomy-list" data-term="{{ $.term }}">
{{/*
Generates a list of the terms for a given taxonomy.
@param {Page} .page The current page
@param {String} .taxonomy The name of the taxonomy
*/}}
{{- $taxonomy := .taxonomy -}}
{{ with .page.GetTerms $taxonomy }}
{{- $name := $taxonomy -}}
{{- with T $taxonomy (len .) }}
{{ $name = . }}
{{ end -}}
<ul class="taxonomy-list" data-name="{{ $name }}">
{{ range . }}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{ end }}