]> juplo.de Git - website/commitdiff
WIP:thymeleaf:taxonomies-on-page
authorKai Moritz <kai@juplo.de>
Sun, 30 Nov 2025 12:27:37 +0000 (13:27 +0100)
committerKai Moritz <kai@juplo.de>
Wed, 3 Dec 2025 18:58:03 +0000 (19:58 +0100)
hugo/themes/thymeleaf/layouts/_partials/terms.html
hugo/themes/thymeleaf/layouts/page.html

index 3e43c53101139eca08b37a526a35ce405341ef29..952719d8656525b819dfc36fca01b4e4448539a8 100644 (file)
@@ -1,53 +1,11 @@
-{{- /*
-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>
+{{- with .Page.Site.Taxonomies }}
+{{- range $taxonomy, $terms := . }}
+<h3>$taxonomy</h3>
+<pre>{{ debug.Dump $taxonomy }}</pre>
+<h3>$terms</h3>
+<pre>{{ debug.Dump $terms }}</pre>
+{{- end }}
 {{- end }}
-    <h3>.Site</h3>
-    <pre>{{ debug.Dump .Site }}</pre>
-    <h3>.</h3>
-    <pre>{{ debug.Dump . }}</pre>
-    <h3>.page</h3>
-    <pre>{{ debug.Dump .page }}</pre>
-    <h3>.Page.Page</h3>
-    <pre>{{ debug.Dump .Page.Page }}</pre>
-    <h3>.tags</h3>
-    <pre>{{ debug.Dump .tags }}</pre>
-    <h3>$taxonomy</h3>
-    <pre>{{ debug.Dump $taxonomy }}</pre>
-    {{- $taxonomyObject := .page.Site.Taxonomies.tags }}
-    <pre>{{ debug.Dump $taxonomyObject }}</pre>
-    {{- $type := $taxonomyObject.Type }}
-    <pre>{{ debug.Dump $type }}</pre>
-    <ul class="terms-tags">
-      {{- range $key, $value := $taxonomyObject.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>
 
 {{- define "custom_css" }}
 <style>
index ff433b27f06b74b7d348b8e65399e098a763fb8a..1f53ceb94f7460cd498e9e6423ea5f5b8b426a89 100644 (file)
@@ -6,8 +6,5 @@
   <time datetime="{{ $dateMachine }}">{{ $dateHuman }}</time>
 
   {{ .Content }}
-  <div>tags</div>
-  {{ partial "terms.html" (dict "taxonomy" "tags" "page" .) }}
-  <div>categories</div>
-  {{ partial "terms.html" (dict "taxonomy" "categories" "page" .) }}
+  {{ partial "terms.html" . }}
 {{ end }}