One file held every fragment, and it gained one per feature all session: figure, gallery, icon, three admonitions, details, aside, contents. A theme author overriding one had to copy the file or redefine into it, and a diff of the theme became a diff of everything. Both forms are supported, because a small theme is happier with one file and the contract should not force a directory on it. Parse order is embedded file, embedded directory, site file, site directory, and the last definition wins — so the directory overrides the file within one source and a site overrides the binary either way. Verified with a site root using both at once: its shortcodes.html supplied `icon`, its shortcodes/note.html supplied `note`, the embedded directory supplied the rest, and with the same name in both the directory won. The embedded theme ships the directory only, seven files, so nothing is defined twice. parseSet takes globs now and lost a branch doing it. Its old guard — a literal embedded name must exist — had to go, since shortcodes.html is deliberately absent; the replacement is stronger, failing at startup when a set matches nothing anywhere, which also catches a renamed base.html.
18 lines
840 B
HTML
18 lines
840 B
HTML
{{/* `sizes` is layout knowledge, so it belongs to whoever wrote the layout. Without it a browser assumes
|
|
100vw and fetches the widest variant for a thumbnail, which makes the derivative pass cost bandwidth
|
|
rather than save it. These values describe *this* stylesheet — a 32rem measure, two gallery columns
|
|
above 36rem — and a theme that changes the layout must change them with it (ADR-0068). */}}
|
|
{{define "figure" -}}
|
|
<figure>
|
|
{{- range .Pictures}}
|
|
<img src="{{.Src}}"{{if .Srcset}} srcset="{{.Srcset}}" sizes="(min-width: 36rem) 32rem, 100vw"{{end}}{{if .Width}} width="{{.Width}}" height="{{.Height}}"{{end}} alt="{{$.Args.alt}}">
|
|
{{- end}}
|
|
{{- if not .Pictures}}
|
|
<img src="{{.Args.src}}" alt="{{.Args.alt}}">
|
|
{{- end}}
|
|
{{- if .Args.caption}}
|
|
<figcaption>{{.Args.caption}}</figcaption>
|
|
{{- end}}
|
|
</figure>
|
|
{{- end}}
|