]> juplo.de Git - website/commitdiff
Partial `terms.html` überarbeitet
authorKai Moritz <kai@juplo.de>
Sun, 30 Nov 2025 08:11:06 +0000 (09:11 +0100)
committerKai Moritz <kai@juplo.de>
Sun, 21 Dec 2025 18:55:03 +0000 (19:55 +0100)
layouts/_partials/terms.html
layouts/page.html

index 8a6ebec2a2cc3967aca21a8d253b130c17fa8d8e..a10e59ec25127f3ac17b9d6c39464e30256d8eef 100644 (file)
@@ -1,23 +1,17 @@
-{{- /*
-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>
+<aside class="m">
+{{- $page := .Page }}
+{{- range .Page.Site.Taxonomies }}
+{{- with $taxonomy := . }}
+{{- $terms := $page.GetTerms .Page.Data.Plural }}
+{{- if gt $terms.Len 0 }}
+<h1>{{ .Page.LinkTitle }}</h1>
+<ul>
+  {{- range $terms }}
+  <li><a href="{{ .Page.RelPermalink }}">{{ .Page.LinkTitle }}</a> <span>{{ $taxonomy.Count .Page.Data.Term }}</span></li>
+  {{- end }}
+</ul>
+<a href="{{ .Page.RelPermalink }}">Show all {{ .Page.LinkTitle }}</a>
 {{- end }}
+{{- end }}
+{{- end }}
+</aside>
index 30fcf482e54166f3973ff7b446a2b20141e83e0e..e6b6060b2aaa3490097ab13e8461348f9e9ab707 100644 (file)
@@ -4,5 +4,7 @@
   <time datetime="{{ $dateMachine }}">{{ $dateHuman }}</time>
 
   {{ .Content }}
-  {{ partial "terms.html" (dict "taxonomy" "tags" "page" .) }}
+{{ end }}
+{{ define "marginalcontent" }}
+  {{ partial "terms.html" . }}
 {{ end }}