]> juplo.de Git - website/commitdiff
thymeleaf-theme: Reworked partial `terms.html`
authorKai Moritz <kai@juplo.de>
Sun, 30 Nov 2025 08:11:06 +0000 (09:11 +0100)
committerKai Moritz <kai@juplo.de>
Tue, 16 Dec 2025 18:45:26 +0000 (19:45 +0100)
layouts/_partials/terms.html
layouts/page.html

index 8a6ebec2a2cc3967aca21a8d253b130c17fa8d8e..550ed41a83c243162a4f67c556da34ca0352c49c 100644 (file)
@@ -1,23 +1,13 @@
-{{- /*
-For a given taxonomy, renders a list of terms assigned to the page.
-
-@context {page} page The current page.
-@context {string} taxonomy The taxonomy.
-
-@example: {{ partial "terms.html" (dict "taxonomy" "tags" "page" .) }}
-*/}}
-
-{{- $page := .page }}
-{{- $taxonomy := .taxonomy }}
-
-{{- with $page.GetTerms $taxonomy }}
-  {{- $label := (index . 0).Parent.LinkTitle }}
-  <div>
-    <div>{{ $label }}:</div>
-    <ul>
-      {{- range . }}
-        <li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
-      {{- end }}
-    </ul>
-  </div>
+{{- $page := .Page }}
+{{- range .Page.Site.Taxonomies }}
+{{- $taxonomy := . }}
+{{- $terms := $page.GetTerms .Page.Data.Plural }}
+{{- if gt $terms.Len 0 }}
+<h3><a href="{{ .Page.RelPermalink }}">{{ .Page.LinkTitle }}</a></h3>
+<ul>
+  {{- range $terms }}
+  <li><a href="{{ .Page.RelPermalink }}">{{ .Page.LinkTitle }}</a> <span>{{ $taxonomy.Count .Page.Data.Term }}</span></li>
+  {{- end }}
+</ul>
+{{- end }}
 {{- end }}
index 30fcf482e54166f3973ff7b446a2b20141e83e0e..53a78e07f3eb5758d66f497e63d91361f6a2e404 100644 (file)
@@ -4,5 +4,5 @@
   <time datetime="{{ $dateMachine }}">{{ $dateHuman }}</time>
 
   {{ .Content }}
-  {{ partial "terms.html" (dict "taxonomy" "tags" "page" .) }}
+  {{ partial "terms.html" . }}
 {{ end }}