Files
khosra/examples/demo-site/templates/list.html
T
Claude Opus 5andbdeshi de1ce73430 track the demo as a real site in examples/, gated like the docs
The human asked for a demo extensive enough to review by hand, tracked as files,
and kept current the way docs are. Generated filler cannot be reviewed — you cannot
read a Go function and see what a reader sees — so the generator is deleted and
`examples/demo-site/` is an ordinary site: 33 Markdown files, six pictures,
site.yaml, a template override and static files.

My reason for generating it was ADR-0011, and I had that rule wrong: it puts the
*author's site root* outside this repository, not fixtures. conventions.md already
keeps golden files in testdata/, and this is the same category one size up. Keeping
both a generator and files would have been two sources of truth, so one had to go.

Kept true by two gates rather than by good intentions. A table-driven test in
internal/web serves the directory through the real handler with one case per
feature — thirty-five of them, each naming what it proves — and verify.sh runs
`khosra check` over it and fails on anything fatal. Adding a feature now means
adding it to the demo and adding its case, and the build says so if you don't.

Extensive on purpose: eleven dated posts so a section actually paginates, a
four-chapter series so first/last are not the neighbours, a gallery with three
JPEGs and an SVG so both the resampled and the untouched paths show, a Bengali-only
bundle, a titleless status, a draft, a future date, an include, a nested extras
tree, and a typography page that demonstrates what the engine will not do.

Two expectations of mine were wrong and the demo corrected them: the site's own
list template overrides *tag* listings too, so there are no group headings there —
which turns out to be the better demonstration of ADR-0046, since the theme picking
the flat shape is exactly the point. And template literal text is not escaped, so
an apostrophe stays an apostrophe.
2026-07-31 20:08:28 +06:00

25 lines
911 B
HTML

{{define "main" -}}
<h1>{{.Title}}</h1>
<p><em>This listing is rendered by the site's own template, parsed after the embedded one. It redefines a
single named block and inherits the whole document around it.</em></p>
{{- if .Items}}
{{- range .Items}}
<article class="entry">
<h2><a href="{{.URL}}">{{if .Title}}{{.Title}}{{else}}{{.Key}}{{end}}</a></h2>
{{- if not .Date.IsZero}}
<p class="meta"><time datetime="{{.Date.Format "2006-01-02"}}">{{day $.Lang .Date}}</time>{{if .Section}} · {{.Section}}{{end}}</p>
{{- end}}
</article>
{{- end}}
{{- else}}
<p>{{t .Lang "empty"}}</p>
{{- end}}
{{- if or .PrevURL .NextURL}}
<nav class="pagination">
{{- if .PrevURL}}<a rel="prev" href="{{.PrevURL}}">{{t .Lang "newer"}}</a>{{end}}
<span>{{t .Lang "page-of" (num .Lang .Page) (num .Lang .Pages)}}</span>
{{- if .NextURL}}<a rel="next" href="{{.NextURL}}">{{t .Lang "older"}}</a>{{end}}
</nav>
{{- end}}
{{- end}}