feat: add category pages and per-category feeds to site builder

Extend the publishing pipeline to generate category index pages,
per-category archive pages, per-category RSS/JSON feeds, and display
categories on individual post pages and post lists.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Leon Mika 2026-03-18 21:51:19 +11:00
parent 4c2ce7272d
commit 6c69131b03
10 changed files with 329 additions and 61 deletions

View file

@ -0,0 +1,9 @@
<h2>Categories</h2>
<ul>
{{ range .Categories }}
<li>
<a href="{{ url_abs .Path }}">{{ .Name }}</a> ({{ .PostCount }})
{{ if .DescriptionBrief }}<br><small>{{ .DescriptionBrief }}</small>{{ end }}
</li>
{{ end }}
</ul>

View file

@ -0,0 +1,16 @@
<h2>{{ .Category.Name }}</h2>
{{ if .DescriptionHTML }}
<div>{{ .DescriptionHTML }}</div>
{{ end }}
{{ range .Posts }}
{{ if .Post.Title }}<h3>{{ .Post.Title }}</h3>{{ end }}
{{ .HTML }}
<a href="{{ url_abs .Path }}">{{ format_date .Post.PublishedAt }}</a>
{{ if .Categories }}
<p>
{{ range .Categories }}
<a href="{{ url_abs (printf "/categories/%s" .Slug) }}">{{ .Name }}</a>
{{ end }}
</p>
{{ end }}
{{ end }}

View file

@ -2,4 +2,11 @@
{{ if .Post.Title }}<h3>{{ .Post.Title }}</h3>{{ end }}
{{ .HTML }}
<a href="{{ url_abs .Path }}">{{ format_date .Post.PublishedAt }}</a>
{{ if .Categories }}
<p>
{{ range .Categories }}
<a href="{{ url_abs (printf "/categories/%s" .Slug) }}">{{ .Name }}</a>
{{ end }}
</p>
{{ end }}
{{ end }}

View file

@ -1,3 +1,10 @@
{{ if .Post.Title }}<h3>{{ .Post.Title }}</h3>{{ end }}
{{ .HTML }}
<a href="{{ url_abs .Path }}">{{ format_date .Post.PublishedAt }}</a>
<a href="{{ url_abs .Path }}">{{ format_date .Post.PublishedAt }}</a>
{{ if .Categories }}
<p>
{{ range .Categories }}
<a href="{{ url_abs (printf "/categories/%s" .Slug) }}">{{ .Name }}</a>
{{ end }}
</p>
{{ end }}