Fix /categories and /tags overview pages: render term cards with images

For kind=taxonomy pages, .Pages contains term pages (not posts), so
card.html was getting no images. Add a separate branch that renders
each term as a cover card using the first post's image, title, and
plate count.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-18 19:05:34 +02:00
parent ab3d80457d
commit 3bdcf7ee60
+50 -7
View File
@@ -1,14 +1,55 @@
{{ define "main" }} {{ define "main" }}
{{/* Category / tag taxonomy list pages */}}
<section id="hero" class="px-[var(--pad)] pt-[clamp(36px,5vw,64px)] pb-[clamp(28px,3.5vw,48px)] border-b border-[var(--rule)]">
{{- if eq .Kind "taxonomy" }} {{- if eq .Kind "taxonomy" }}
<div class="font-sans font-medium text-[10px] leading-none tracking-[.22em] uppercase text-ink-soft mb-4">{{ .Type | humanize }}</div> {{/* ── Taxonomy overview: /categories/ or /tags/ ── */}}
<h1 class="font-display font-normal text-[clamp(48px,7vw,96px)] leading-[0.94] m-0 mb-4"><em>{{ .Title }}</em></h1> <section id="hero" class="px-[var(--pad)] pt-[clamp(36px,5vw,64px)] pb-[clamp(28px,3.5vw,48px)] border-b border-[var(--rule)]">
<div class="font-sans font-medium text-[10px] leading-none tracking-[.22em] uppercase text-ink-soft mb-4">Archive</div>
<h1 class="font-display font-normal text-[clamp(48px,7vw,96px)] leading-[0.94] m-0 mb-4">The <em>{{ .Title | lower }}</em></h1>
<p class="font-serif italic text-[clamp(13px,1vw,16px)] leading-[1.65] text-ink-2 max-w-[55ch] m-0"> <p class="font-serif italic text-[clamp(13px,1vw,16px)] leading-[1.65] text-ink-2 max-w-[55ch] m-0">
{{ len .Pages }} {{ if eq (len .Pages) 1 }}plate{{ else }}plates{{ end }} in this section. {{ len .Pages }} {{ .Title | lower | singularize }}{{ if ne (len .Pages) 1 }}s{{ end }} across the archive.
<a href="/" class="border-b border-current">Return to archive →</a> <a href="/" class="border-b border-current ml-1">Return to home →</a>
</p> </p>
{{- else if eq .Kind "term" }} </section>
<div class="grid [grid-template-columns:repeat(auto-fill,minmax(220px,1fr))] gap-[var(--gap)] px-[var(--pad)] py-[var(--gap)]">
{{- range $i, $term := .Pages }}
{{- $firstPost := index $term.Pages 0 }}
{{- $img := "" }}
{{- if $firstPost }}{{- $img = $firstPost.Resources.GetMatch "*.png" }}{{- end }}
<a href="{{ $term.RelPermalink }}"
style="--d:{{ mul (math.Min $i 18) 24 }}ms"
class="card group block cursor-pointer">
<div class="relative aspect-[2/3] overflow-hidden bg-paper-2 rounded-[1px]
after:content-[''] after:absolute after:inset-0
after:shadow-[inset_0_0_0_1px_rgba(22,17,13,.04)] after:pointer-events-none">
{{- if $img }}
{{- $w := $img.Resize "600x900 webp" }}
<picture>
<source srcset="{{ $w.RelPermalink }}" type="image/webp" />
<img class="card-img w-full h-full object-cover
transition-[transform,filter] [transition-duration:.9s,.6s]
[transition-timing-function:cubic-bezier(.2,.7,.1,1),ease]
[filter:saturate(.92)_contrast(1.02)]"
loading="{{ if lt $i 8 }}eager{{ else }}lazy{{ end }}"
src="{{ $w.RelPermalink }}"
alt="{{ $term.Title }}" />
</picture>
{{- end }}
<span class="absolute bottom-[10px] left-[10px]
font-sans font-medium text-[10px] leading-none tracking-[.18em] uppercase
text-paper mix-blend-difference tabular-nums">{{ len $term.Pages }} plates</span>
</div>
<div class="mt-[14px] grid gap-1">
<h2 class="font-display font-normal text-[clamp(20px,1.6vw,26px)] leading-[1.1] tracking-normal m-0">{{ $term.Title }}</h2>
</div>
</a>
{{- end }}
</div>
{{- else }}
{{/* ── Term page (/categories/gothic/) or plain list ── */}}
<section id="hero" class="px-[var(--pad)] pt-[clamp(36px,5vw,64px)] pb-[clamp(28px,3.5vw,48px)] border-b border-[var(--rule)]">
{{- if eq .Kind "term" }}
<div class="font-sans font-medium text-[10px] leading-none tracking-[.22em] uppercase text-ink-soft mb-4">{{ .Type | humanize | singularize }}</div> <div class="font-sans font-medium text-[10px] leading-none tracking-[.22em] uppercase text-ink-soft mb-4">{{ .Type | humanize | singularize }}</div>
<h1 class="font-display font-normal text-[clamp(48px,7vw,96px)] leading-[0.94] m-0 mb-4"><em>{{ .Title }}</em></h1> <h1 class="font-display font-normal text-[clamp(48px,7vw,96px)] leading-[0.94] m-0 mb-4"><em>{{ .Title }}</em></h1>
<p class="font-serif italic text-[clamp(13px,1vw,16px)] leading-[1.65] text-ink-2 max-w-[55ch] m-0"> <p class="font-serif italic text-[clamp(13px,1vw,16px)] leading-[1.65] text-ink-2 max-w-[55ch] m-0">
@@ -34,4 +75,6 @@
{{- end }} {{- end }}
</section> </section>
{{- partial "pagination.html" $paginator }} {{- partial "pagination.html" $paginator }}
{{- end }}
{{ end }} {{ end }}