]> juplo.de Git - website/commitdiff
WIP:refactor: display terms as term/number-buttons
authorKai Moritz <kai@juplo.de>
Sat, 22 Nov 2025 15:12:02 +0000 (16:12 +0100)
committerKai Moritz <kai@juplo.de>
Sat, 22 Nov 2025 15:12:02 +0000 (16:12 +0100)
hugo/themes/thymeleaf/layouts/_partials/terms.html

index 8a6ebec2a2cc3967aca21a8d253b130c17fa8d8e..6fd26540b790cdb8a6f3be4ab13aed28ea9905a8 100644 (file)
@@ -1,23 +1,27 @@
-{{- /*
-For a given taxonomy, renders a list of terms assigned to the page.
+{{- define "main" }}
 
-@context {page} page The current page.
-@context {string} taxonomy The taxonomy.
-
-@example: {{ partial "terms.html" (dict "taxonomy" "tags" "page" .) }}
-*/}}
+{{- if .Title }}
+<header class="page-header">
+    <h1>{{ .Title }}</h1>
+    {{- if .Description }}
+    <div class="post-description">
+        {{ .Description }}
+    </div>
+    {{- end }}
+</header>
+{{- end }}
 
-{{- $page := .page }}
-{{- $taxonomy := .taxonomy }}
+<ul class="terms-tags">
+    {{- $type := .Type }}
+    {{- range $key, $value := .Data.Terms.Alphabetical }}
+    {{- $name := .Name }}
+    {{- $count := .Count }}
+    {{- with site.GetPage (printf "/%s/%s" $type $name) }}
+    <li>
+        <a href="{{ .Permalink }}">{{ .Name }} <sup><strong><sup>{{ $count }}</sup></strong></sup> </a>
+    </li>
+    {{- end }}
+    {{- end }}
+</ul>
 
-{{- 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>
-{{- end }}
+{{- end }}{{/* end main */ -}}