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:
@@ -1,14 +1,55 @@
|
||||
{{ define "main" }}
|
||||
{{/* Category / tag taxonomy list pages */}}
|
||||
|
||||
{{- if eq .Kind "taxonomy" }}
|
||||
{{/* ── Taxonomy overview: /categories/ or /tags/ ── */}}
|
||||
<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" }}
|
||||
<div class="font-sans font-medium text-[10px] leading-none tracking-[.22em] uppercase text-ink-soft mb-4">{{ .Type | humanize }}</div>
|
||||
<h1 class="font-display font-normal text-[clamp(48px,7vw,96px)] leading-[0.94] m-0 mb-4"><em>{{ .Title }}</em></h1>
|
||||
<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">
|
||||
{{ len .Pages }} {{ if eq (len .Pages) 1 }}plate{{ else }}plates{{ end }} in this section.
|
||||
<a href="/" class="border-b border-current">Return to archive →</a>
|
||||
{{ len .Pages }} {{ .Title | lower | singularize }}{{ if ne (len .Pages) 1 }}s{{ end }} across the archive.
|
||||
<a href="/" class="border-b border-current ml-1">Return to home →</a>
|
||||
</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>
|
||||
<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">
|
||||
@@ -34,4 +75,6 @@
|
||||
{{- end }}
|
||||
</section>
|
||||
{{- partial "pagination.html" $paginator }}
|
||||
|
||||
{{- end }}
|
||||
{{ end }}
|
||||
|
||||
Reference in New Issue
Block a user