@heroiclands/package-build 22.22.0 → 22.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +1 -0
  3. package/bin/content-commands.mjs +51 -14
  4. package/ci/content-format-reference.mjs +1 -1
  5. package/content-config.mjs +80 -2
  6. package/docs/api.md +85 -72
  7. package/docs/authoring/assets.md +29 -0
  8. package/docs/authoring/dates-and-calendars.md +37 -1
  9. package/docs/authoring/links-and-markup.md +112 -31
  10. package/docs/commands.md +30 -29
  11. package/docs/configuration.md +92 -19
  12. package/docs/content-format.md +1 -1
  13. package/docs/guides/book.md +5 -4
  14. package/docs/guides/module-project.md +2 -2
  15. package/docs/guides/site.md +41 -0
  16. package/docs/project-setup.md +4 -4
  17. package/docs/reference/format-details.md +323 -60
  18. package/docs/reference/note-types.md +9 -9
  19. package/docs/reference/theme-pages.md +496 -0
  20. package/engine/anchors.mjs +16 -10
  21. package/engine/art-fields.mjs +118 -0
  22. package/engine/art-slots.mjs +9 -2
  23. package/engine/asset-index.mjs +160 -10
  24. package/engine/asset-replacement.mjs +93 -0
  25. package/engine/asset-types.mjs +240 -0
  26. package/engine/base-compiler.mjs +54 -2
  27. package/engine/bundles.mjs +13 -1
  28. package/engine/content-blocks.mjs +4 -4
  29. package/engine/content-embeds.mjs +19 -0
  30. package/engine/content-figures.mjs +468 -0
  31. package/engine/content-footnotes.mjs +10 -2
  32. package/engine/content-format.yaml +1 -1
  33. package/engine/content-images.mjs +126 -25
  34. package/engine/content-index.mjs +36 -10
  35. package/engine/field-reference.mjs +31 -10
  36. package/engine/field-spec.mjs +10 -8
  37. package/engine/foreign-catalog.mjs +145 -19
  38. package/engine/frontmatter-lint.mjs +73 -1
  39. package/engine/heading-attributes.mjs +31 -18
  40. package/engine/helpers.mjs +102 -33
  41. package/engine/infobox-registry.mjs +4 -1
  42. package/engine/infobox.mjs +47 -8
  43. package/engine/itinerary-scenes.mjs +4 -10
  44. package/engine/journals.mjs +264 -39
  45. package/engine/lore-events.mjs +197 -0
  46. package/engine/markdown-expressions.mjs +257 -7
  47. package/engine/note-dates.mjs +305 -12
  48. package/engine/note-vocabulary.mjs +11 -5
  49. package/engine/pathnames.mjs +36 -0
  50. package/engine/pdf-build.mjs +357 -34
  51. package/engine/pdf-images.mjs +64 -0
  52. package/engine/pdf-render.mjs +160 -36
  53. package/engine/scenes.mjs +16 -4
  54. package/engine/site-build.mjs +127 -13
  55. package/engine/site-config.mjs +19 -24
  56. package/engine/site-index.mjs +72 -1
  57. package/engine/site-preview.mjs +2 -0
  58. package/engine/system-block.mjs +44 -16
  59. package/hm3/actors.mjs +2 -2
  60. package/hugo-theme/data/banners.yaml +69 -0
  61. package/hugo-theme/layouts/404.html +85 -0
  62. package/hugo-theme/layouts/_default/baseof.html +64 -0
  63. package/hugo-theme/layouts/_default/list.html +139 -0
  64. package/hugo-theme/layouts/_default/single.html +4 -0
  65. package/hugo-theme/layouts/blog/list.html +54 -0
  66. package/hugo-theme/layouts/blog-post/single.html +36 -0
  67. package/hugo-theme/layouts/index.html +75 -0
  68. package/hugo-theme/layouts/partials/banner-url.html +117 -0
  69. package/hugo-theme/layouts/partials/cdn-url.html +36 -0
  70. package/hugo-theme/layouts/partials/draft-notice.html +41 -0
  71. package/hugo-theme/layouts/partials/draft-state.html +26 -0
  72. package/hugo-theme/layouts/partials/footer.html +29 -0
  73. package/hugo-theme/layouts/partials/header.html +35 -0
  74. package/hugo-theme/layouts/partials/hero-banner.html +86 -0
  75. package/hugo-theme/layouts/partials/holdings/entry.html +21 -0
  76. package/hugo-theme/layouts/partials/holdings/kind-groups.html +71 -0
  77. package/hugo-theme/layouts/partials/holdings.html +61 -0
  78. package/hugo-theme/layouts/partials/infobox/entry.html +15 -0
  79. package/hugo-theme/layouts/partials/infobox/items.html +26 -0
  80. package/hugo-theme/layouts/partials/infobox/section.html +56 -0
  81. package/hugo-theme/layouts/partials/infobox/value.html +43 -0
  82. package/hugo-theme/layouts/partials/infobox.html +57 -0
  83. package/hugo-theme/layouts/partials/page-body.html +154 -0
  84. package/hugo-theme/layouts/partials/place-map.html +9 -0
  85. package/hugo-theme/layouts/partials/related.html +121 -0
  86. package/hugo-theme/layouts/partials/search.html +84 -0
  87. package/hugo-theme/layouts/partials/site-url.html +32 -0
  88. package/hugo-theme/layouts/partials/tags.html +30 -0
  89. package/hugo-theme/layouts/partials/toc.html +28 -0
  90. package/hugo-theme/layouts/partials/warn-missing-banner.html +3 -0
  91. package/hugo-theme/layouts/shortcodes/cartouche.html +64 -0
  92. package/hugo-theme/layouts/shortcodes/exturl.html +12 -0
  93. package/hugo-theme/layouts/shortcodes/glyph.html +43 -0
  94. package/hugo-theme/layouts/shortcodes/pagelist.html +63 -0
  95. package/hugo-theme/static/css/sohl-icons.css +57 -0
  96. package/hugo-theme/static/css/style.css +2953 -0
  97. package/hugo-theme/static/fonts/game-icons-kb.woff2 +0 -0
  98. package/hugo-theme/static/img/banners/takheperu-hieroglyphs.svg +1 -0
  99. package/hugo-theme/static/img/cartouches/takheperu.svg +1 -0
  100. package/hugo-theme/theme.toml +11 -0
  101. package/manifest.mjs +30 -24
  102. package/package.json +2 -1
  103. package/packagebuild-metadata.jsonl +13 -13
  104. package/sohl/item-fields.mjs +4 -3
  105. package/types/content-config.d.mts +48 -1
  106. package/types/engine/anchors.d.mts +9 -4
  107. package/types/engine/art-fields.d.mts +64 -0
  108. package/types/engine/art-slots.d.mts +2 -1
  109. package/types/engine/asset-index.d.mts +43 -0
  110. package/types/engine/asset-replacement.d.mts +22 -0
  111. package/types/engine/asset-types.d.mts +18 -0
  112. package/types/engine/base-compiler.d.mts +0 -17
  113. package/types/engine/content-embeds.d.mts +16 -0
  114. package/types/engine/content-figures.d.mts +101 -0
  115. package/types/engine/content-footnotes.d.mts +7 -0
  116. package/types/engine/content-images.d.mts +78 -12
  117. package/types/engine/content-index.d.mts +8 -2
  118. package/types/engine/field-reference.d.mts +21 -0
  119. package/types/engine/field-spec.d.mts +20 -16
  120. package/types/engine/foreign-catalog.d.mts +39 -0
  121. package/types/engine/heading-attributes.d.mts +13 -8
  122. package/types/engine/helpers.d.mts +28 -10
  123. package/types/engine/infobox-registry.d.mts +4 -1
  124. package/types/engine/infobox.d.mts +6 -0
  125. package/types/engine/journals.d.mts +31 -9
  126. package/types/engine/lore-events.d.mts +14 -0
  127. package/types/engine/markdown-expressions.d.mts +23 -2
  128. package/types/engine/note-dates.d.mts +64 -1
  129. package/types/engine/pathnames.d.mts +26 -0
  130. package/types/engine/pdf-build.d.mts +28 -6
  131. package/types/engine/pdf-images.d.mts +52 -0
  132. package/types/engine/pdf-render.d.mts +12 -0
  133. package/types/engine/site-build.d.mts +14 -3
  134. package/types/engine/site-config.d.mts +9 -9
  135. package/types/engine/site-index.d.mts +54 -0
  136. package/types/engine/system-block.d.mts +26 -2
  137. package/types/hm3/actors.d.mts +18 -0
  138. package/types/manifest.d.mts +19 -23
  139. package/engine/content-captions.mjs +0 -230
  140. package/types/engine/content-captions.d.mts +0 -58
@@ -0,0 +1,61 @@
1
+ {{- /*
2
+ Holdings card.
3
+
4
+ Three small tables, rendered after the body and before the Related card
5
+ (see `page-body.html`), from front matter `@heroiclands/package-build`
6
+ derives and a note never authors itself:
7
+
8
+ contains: [{ title, url, type, subType }] places sitting within this one
9
+ held_by: [{ title, url, type, subType }] affiliations holding this place
10
+ holdings: [{ title, url, type, subType }] places this affiliation holds
11
+
12
+ A place page carries `contains` and/or `held_by`; an affiliation page
13
+ carries `holdings`. Neither is checked here — presence of the key is the
14
+ only test, the same silent-disappear convention the Related card follows:
15
+ a page carrying none of the three renders no card at all.
16
+
17
+ `contains` and `holdings` list places, so each is broken into groups by
18
+ kind (`holdings/kind-groups.html`) — the towns together, the hamlets
19
+ together. `held_by` lists affiliations, whose kinds have no fixed
20
+ hierarchy to group by, so it stays one flat grid with the kind printed
21
+ beside each name instead of as a group heading.
22
+
23
+ An entry's `url` is absent for a stub — a note with an empty body, which
24
+ carries its facts into every list that names it but publishes no page of
25
+ its own. `holdings/entry.html` renders such an entry as plain text and
26
+ every other entry as a link — see it for the guard and how its correctness
27
+ was established.
28
+ */ -}}
29
+ {{- $within := .Params.contains -}}
30
+ {{- $heldBy := .Params.held_by -}}
31
+ {{- $holds := .Params.holdings -}}
32
+
33
+ {{- if or $within $heldBy $holds -}}
34
+ <section class="holdings" data-pagefind-ignore>
35
+ {{- with $within }}
36
+ <div class="holdings-table">
37
+ <h3 class="holdings-table-label">Within</h3>
38
+ {{ partial "holdings/kind-groups.html" . }}
39
+ </div>
40
+ {{- end }}
41
+ {{- with $heldBy }}
42
+ <div class="holdings-table">
43
+ <h3 class="holdings-table-label">Held by</h3>
44
+ <ul class="holdings-table-grid">
45
+ {{- range . }}
46
+ <li>
47
+ {{- partial "holdings/entry.html" (dict "entry" . "class" "holdings-entry-name") -}}
48
+ {{- with .subType }}<span class="holdings-entry-kind"> ({{ humanize . }})</span>{{ end -}}
49
+ </li>
50
+ {{- end }}
51
+ </ul>
52
+ </div>
53
+ {{- end }}
54
+ {{- with $holds }}
55
+ <div class="holdings-table">
56
+ <h3 class="holdings-table-label">Holdings</h3>
57
+ {{ partial "holdings/kind-groups.html" . }}
58
+ </div>
59
+ {{- end }}
60
+ </section>
61
+ {{- end -}}
@@ -0,0 +1,15 @@
1
+ {{- /*
2
+ One entry of a `runin` group or a `list` section.
3
+
4
+ An entry is `{text, url}`. It links when the build reached the page it
5
+ names, and keeps its words when it did not — a panel naming something this
6
+ site does not publish is better than a panel silently one entry short.
7
+
8
+ Takes `entry` and the `class` its medium gives it.
9
+ */ -}}
10
+ {{- $entry := .entry -}}
11
+ {{- with $entry.url -}}
12
+ <a class="{{ $.class }}" href="{{ . }}">{{ $entry.text }}</a>
13
+ {{- else -}}
14
+ <span class="{{ $.class }}">{{ $entry.text }}</span>
15
+ {{- end -}}
@@ -0,0 +1,26 @@
1
+ {{- /*
2
+ What one infobox section holds, whatever its layout.
3
+
4
+ A section carries its content under the key its layout names — `rows`,
5
+ `cells`, `groups` or `entries` — so one lookup answers "is there anything to
6
+ draw?" for every layout there is. Returns a slice, empty when there is
7
+ nothing.
8
+
9
+ Takes the section. Returns the items.
10
+
11
+ An unrecognised layout returns nothing and says so once: the four layouts
12
+ are a closed set, so a fifth means this theme is older than the content it
13
+ is drawing, and a silently dropped section is the expensive way to find out.
14
+ */ -}}
15
+ {{- $section := . -}}
16
+ {{- $layout := $section.layout | default "" -}}
17
+ {{- $key := index (dict "rows" "rows" "grid" "cells" "runin" "groups" "list" "entries") $layout -}}
18
+ {{- $items := slice -}}
19
+ {{- with $key -}}
20
+ {{- with index $section . -}}
21
+ {{- $items = . -}}
22
+ {{- end -}}
23
+ {{- else -}}
24
+ {{- warnidf "infobox-unknown-layout" "infobox: section layout %q is not one of rows, grid, runin or list, so the section is not drawn. Upgrade @heroiclands/hugo-theme to a version that draws it." $layout -}}
25
+ {{- end -}}
26
+ {{- return $items -}}
@@ -0,0 +1,56 @@
1
+ {{- /*
2
+ One infobox section, arranged the way its `layout` says.
3
+
4
+ Four layouts, a closed set, and the key a section carries its content under
5
+ is what names it:
6
+
7
+ rows — label/value pairs, one per line `rows`
8
+ grid — short label/value cells packed together `cells`
9
+ runin — groups of comma-joined entries `groups`
10
+ list — one entry per line `entries`
11
+
12
+ Takes the section.
13
+
14
+ **A value of `0` is a value.** Armour that stops nothing edged is a fact
15
+ about the armour, so a cell is printed as it comes rather than guarded with
16
+ `with`, which would drop a zero along with an absence.
17
+ */ -}}
18
+ {{- $section := . -}}
19
+ {{- $layout := $section.layout | default "" -}}
20
+ {{- if eq $layout "rows" -}}
21
+ <dl class="info-profile-grid">
22
+ {{- range $section.rows }}
23
+ <dt>{{ .label }}</dt>
24
+ <dd>{{ partial "infobox/value.html" . }}</dd>
25
+ {{- end }}
26
+ </dl>
27
+ {{- else if eq $layout "grid" -}}
28
+ <div class="info-attrs-grid">
29
+ {{- range $section.cells }}
30
+ <div class="info-attr">
31
+ <span class="attr-label">{{ .label }}</span>
32
+ <span class="attr-value">{{ .value }}</span>
33
+ </div>
34
+ {{- end }}
35
+ </div>
36
+ {{- else if eq $layout "runin" -}}
37
+ {{- range $section.groups }}
38
+ <p class="info-skill-line">
39
+ {{- with .label }}<span class="skill-cat">{{ . }}:</span>{{ end }}
40
+ <span class="skill-entries">
41
+ {{- range $i, $entry := .entries -}}
42
+ {{- if $i }}, {{ end -}}
43
+ {{- partial "infobox/entry.html" (dict "entry" $entry "class" "skill-entry") -}}
44
+ {{- end -}}
45
+ </span>
46
+ </p>
47
+ {{- end }}
48
+ {{- else if eq $layout "list" -}}
49
+ <ul class="info-mystical-list">
50
+ {{- range $section.entries }}
51
+ <li class="info-mystical-item">
52
+ {{- partial "infobox/entry.html" (dict "entry" . "class" "mystical-name") -}}
53
+ </li>
54
+ {{- end }}
55
+ </ul>
56
+ {{- end -}}
@@ -0,0 +1,43 @@
1
+ {{- /*
2
+ One row's value, drawn by its `kind`.
3
+
4
+ Five kinds, a closed set:
5
+
6
+ text — a string
7
+ number — a number
8
+ link — `{text, url}`
9
+ links — a list of those, comma-joined
10
+ list — a list of strings, comma-joined
11
+
12
+ Takes the row.
13
+
14
+ **A value of `0` is a value**, so a number is printed as it comes rather
15
+ than guarded with `with`, which would drop a zero along with an absence.
16
+ Anything the build did not classify is set as text, which is what an
17
+ unlabelled scalar is.
18
+ */ -}}
19
+ {{- $kind := .kind | default "text" -}}
20
+ {{- if eq $kind "link" -}}
21
+ {{- partial "infobox/entry.html" (dict "entry" .value "class" "info-link") -}}
22
+ {{- else if eq $kind "links" -}}
23
+ {{- range $i, $entry := .value -}}
24
+ {{- if $i }}, {{ end -}}
25
+ {{- partial "infobox/entry.html" (dict "entry" $entry "class" "info-link") -}}
26
+ {{- end -}}
27
+ {{- else if eq $kind "list" -}}
28
+ {{- delimit .value ", " -}}
29
+ {{- else if eq $kind "number" -}}
30
+ {{- /* A whole number is grouped, so a population reads as 500,000 rather
31
+ than as a run of digits a reader has to count. Grouping is
32
+ typography and belongs to the medium; the number itself is the
33
+ build's. Anything that is not a plain integer — a measurement, or a
34
+ value the build did not classify — is set as written. */ -}}
35
+ {{- $digits := printf "%v" .value -}}
36
+ {{- if findRE `^-?[0-9]+$` $digits -}}
37
+ {{- lang.FormatNumberCustom 0 (int $digits) -}}
38
+ {{- else -}}
39
+ {{- .value -}}
40
+ {{- end -}}
41
+ {{- else -}}
42
+ {{- .value -}}
43
+ {{- end -}}
@@ -0,0 +1,57 @@
1
+ {{- /*
2
+ The infobox rail — every box a page declares, drawn in the order declared.
3
+
4
+ **The content is not decided here.** A page's `infoboxes:` front matter
5
+ carries an ordered list of boxes, each holding ordered sections, each holding
6
+ ordered rows, cells, groups or entries, already labelled. This partial and
7
+ the three under `infobox/` switch on a section's `layout` and a value's
8
+ `kind` and on nothing else — never on a note type, never on a field name.
9
+ That is what lets a field added to a type appear here with no edit.
10
+
11
+ A box is a `<details>` disclosure, open by default: native, accessible, and
12
+ no JavaScript. It is what lets several boxes stack for nothing — a note box
13
+ and one box per system are three summary lines when closed, rather than
14
+ three panels burying the prose.
15
+
16
+ Two kinds of box, and they answer emptiness differently:
17
+
18
+ - A **note box** with no section holding anything is not drawn. A heading
19
+ over nothing asserts a fact that is not there.
20
+ - A **system box** carries a `statement` where it has nothing to show, and
21
+ the statement is drawn in place of the sections. Which silence this is —
22
+ the system compiled no document, or it compiled one holding nothing the
23
+ profile has not already said — is decided by the build, because a reader
24
+ meeting one page cannot tell the two apart and neither can a template. A
25
+ system that does not map the note's type at all sends no box, and nothing
26
+ is drawn.
27
+
28
+ Returns an empty string when the page declares no box, so a caller can test
29
+ what comes back rather than reaching into the data itself.
30
+ */ -}}
31
+ {{- range .Params.infoboxes -}}
32
+ {{- $box := . -}}
33
+ {{- $sections := slice -}}
34
+ {{- range $box.sections -}}
35
+ {{- if gt (len (partial "infobox/items.html" .)) 0 -}}
36
+ {{- $sections = $sections | append . -}}
37
+ {{- end -}}
38
+ {{- end -}}
39
+ {{- $system := eq ($box.kind | default "") "system" -}}
40
+ {{- if or $system (gt (len $sections) 0) }}
41
+ <details class="info-sidebar info-box{{ with $box.id }} info-box-{{ . }}{{ end }}" open data-pagefind-ignore>
42
+ <summary class="info-sidebar-title"><h2>{{ $box.title }}</h2></summary>
43
+ {{- with $box.statement }}
44
+ <p class="info-statement">{{ . }}</p>
45
+ {{- else }}
46
+ {{- range $sections }}
47
+ <section class="info-section{{ with .id }} info-section-{{ . }}{{ end }}">
48
+ {{- with .label }}
49
+ <h3 class="info-section-title">{{ . }}</h3>
50
+ {{- end }}
51
+ {{ partial "infobox/section.html" . }}
52
+ </section>
53
+ {{- end }}
54
+ {{- end }}
55
+ </details>
56
+ {{- end -}}
57
+ {{- end -}}
@@ -0,0 +1,154 @@
1
+ {{- /*
2
+ A note's body — the infobox rail, the content, and prev/next through its
3
+ catalog. Shared by `_default/single.html`, for a page, and `index.html`,
4
+ for the homepage note rendered as a page: the two are the same family, and
5
+ this is the shape they share. The caller renders the hero; this partial
6
+ starts at the article.
7
+
8
+ Context: the page.
9
+ */ -}}
10
+ {{- /* The boxes a page declares, drawn by one generic renderer. What each box
11
+ holds is decided by the build and carried in `infoboxes:` front matter;
12
+ this file decides only where the rail goes. A page declaring none gets
13
+ back an empty string and no rail. */ -}}
14
+ {{- $infobox := partial "infobox.html" . -}}
15
+ {{- $hasSidebar := ne (trim $infobox " \r\n\t") "" -}}
16
+
17
+ {{- /* The TOC partial only emits markup when the page has more than
18
+ 3 H2 headings. To avoid laying the page out as a two-column
19
+ grid for nothing, detect the same condition here so we can
20
+ apply the `.single-with-toc` class conditionally. A page that
21
+ already has a rail gets its contents list at the foot of that
22
+ rail rather than a second column. */ -}}
23
+ {{- $h2Count := len (findRE `(?m)^##\s+\S` (.RawContent | default "")) -}}
24
+ {{- $hasToc := gt $h2Count 3 -}}
25
+
26
+ {{- /* A draft page states it, which also decides the article's first grid
27
+ row — see the notice partial and `.single-with-notice`. */ -}}
28
+ {{- $isDraft := partial "draft-state.html" . -}}
29
+
30
+ <article class="single{{ if $hasSidebar }} single-with-sidebar{{ else if $hasToc }} single-with-toc{{ end }}{{ if $isDraft }} single-with-notice{{ end }}">
31
+ {{- /* A statement about the page rather than about its subject, so it leads
32
+ the article: above the rail and above the prose, at every width. It
33
+ spans the grid for that reason — inside `.single-content` it would sit
34
+ beside the boxes on a wide screen and below them on a narrow one,
35
+ where the rail comes first. */ -}}
36
+ {{ partial "draft-notice.html" . }}
37
+ {{- /* Filter values a search can narrow on, invisible and excluded from
38
+ indexing themselves — `data-pagefind-filter` is read wherever it
39
+ sits, `data-pagefind-body`/`data-pagefind-ignore` scoping included
40
+ (see the README's "Search" section). */ -}}
41
+ {{- with .Params.type }}<span data-pagefind-filter="type" hidden>{{ . }}</span>{{ end -}}
42
+ {{- with .Params.package }}<span data-pagefind-filter="package" hidden>{{ . }}</span>{{ end -}}
43
+ {{- if $hasSidebar }}
44
+ {{- /* The rail comes first in document order, because the infobox is
45
+ generated content prepended before the prose: on a narrow screen the
46
+ grid collapses and the boxes land where they were written, above the
47
+ text they summarise. */ -}}
48
+ <aside class="info-rail">
49
+ {{ $infobox }}
50
+ {{ if $hasToc }}{{ partial "toc.html" . }}{{ end }}
51
+ </aside>
52
+ {{- end }}
53
+ <div class="single-content">
54
+ {{- $tagChips := partial "tags.html" . -}}
55
+ {{- $beingSubtype := "" -}}
56
+ {{- if and (eq .Params.type "being") .Params.subType -}}
57
+ {{- $beingSubtype = cond (eq .Params.subType "npc") "NPC" (humanize .Params.subType) -}}
58
+ {{- end -}}
59
+ {{ if or .Params.date (ne (trim $tagChips " \r\n\t") "") $beingSubtype }}
60
+ <div class="single-meta">
61
+ {{ if .Params.date }}
62
+ <time class="single-date" datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "January 2, 2006" }}</time>
63
+ {{ end }}
64
+ {{- with $beingSubtype }}<span class="single-subtype">{{ . }}</span>{{ end }}
65
+ {{ $tagChips }}
66
+ </div>
67
+ {{ end }}
68
+
69
+ <div class="single-body" data-pagefind-body>
70
+ {{ .Content }}
71
+ </div>
72
+
73
+ {{ partial "holdings.html" . }}
74
+ {{ partial "place-map.html" . }}
75
+ {{ partial "related.html" . }}
76
+
77
+ {{- /*
78
+ Prev/next walk the page's own catalog, not its Hugo section (issue #48).
79
+ `.PrevInSection` / `.NextInSection` mean "the neighbouring page in this
80
+ directory", which was the same thing only while a page lived in a
81
+ directory named for its catalog. `@heroiclands/package-build`
82
+ (package-build#204) emits every content page flat under the content
83
+ mount, so a consumer's whole catalog is one section and these two links
84
+ would walk every page of every type — reading through the afflictions
85
+ silently left them.
86
+
87
+ So where a section holds more than one catalog, the sibling set is
88
+ narrowed to the pages sharing this page's catalog key. A section holding
89
+ a single catalog is left alone, because `.PrevInSection` already walks
90
+ exactly that catalog there — which is what makes this a no-op for a site
91
+ whose pages still sit in catalog-named directories. A page declaring no
92
+ catalog keeps the section-scoped result. The home page declares no
93
+ catalog and has no section siblings either way.
94
+
95
+ The catalog key: `type` for structured content, whose type *is* its
96
+ catalog (`affliction`, `skill`, `weapongear`, …); for `type: doc`, which
97
+ is prose rather than a catalog of its own, `subType` (what package-build
98
+ compiles from a note's classification) or, failing that, `category`
99
+ (what a documentation tree mounted from a repository directory
100
+ carries); "" for a page with no `type`, which has no catalog.
101
+
102
+ Ordering follows Hugo's: in a page collection `.PrevInSection` is the
103
+ *following* entry and `.NextInSection` the preceding one, so the
104
+ neighbours are taken at index+1 and index-1 respectively.
105
+ */ -}}
106
+ {{- $prev := .PrevInSection -}}
107
+ {{- $next := .NextInSection -}}
108
+ {{- $type := .Params.type | default "" -}}
109
+ {{- $key := $type -}}
110
+ {{- if eq $type "doc" -}}
111
+ {{- $key = .Params.subType | default (.Params.category | default "") -}}
112
+ {{- end -}}
113
+ {{- $siblings := slice -}}
114
+ {{- with .CurrentSection -}}
115
+ {{- if $key -}}
116
+ {{- $mixed := false -}}
117
+ {{- $matching := slice -}}
118
+ {{- range .RegularPages -}}
119
+ {{- $pageType := .Params.type | default "" -}}
120
+ {{- $pageKey := $pageType -}}
121
+ {{- if eq $pageType "doc" -}}
122
+ {{- $pageKey = .Params.subType | default (.Params.category | default "") -}}
123
+ {{- end -}}
124
+ {{- if eq $pageKey $key -}}
125
+ {{- $matching = $matching | append . -}}
126
+ {{- else if ne $pageKey "" -}}
127
+ {{- $mixed = true -}}
128
+ {{- end -}}
129
+ {{- end -}}
130
+ {{- if $mixed -}}{{- $siblings = $matching -}}{{- end -}}
131
+ {{- end -}}
132
+ {{- end -}}
133
+ {{- if $siblings -}}
134
+ {{- $index := -1 -}}
135
+ {{- range $i, $p := $siblings -}}
136
+ {{- if eq $p.Path $.Path -}}{{- $index = $i -}}{{- end -}}
137
+ {{- end -}}
138
+ {{- if ge $index 0 -}}
139
+ {{- $prev = "" -}}
140
+ {{- $next = "" -}}
141
+ {{- if lt (add $index 1) (len $siblings) -}}{{- $prev = index $siblings (add $index 1) -}}{{- end -}}
142
+ {{- if gt $index 0 -}}{{- $next = index $siblings (sub $index 1) -}}{{- end -}}
143
+ {{- end -}}
144
+ {{- end -}}
145
+ <nav class="single-nav">
146
+ {{ with $prev }}<a href="{{ .Permalink }}" class="nav-prev">&larr; {{ .Title }}</a>{{ end }}
147
+ {{ with $next }}<a href="{{ .Permalink }}" class="nav-next">{{ .Title }} &rarr;</a>{{ end }}
148
+ </nav>
149
+ </div>
150
+
151
+ {{ if and (not $hasSidebar) $hasToc }}
152
+ {{ partial "toc.html" . }}
153
+ {{ end }}
154
+ </article>
@@ -0,0 +1,9 @@
1
+ {{- /* A page bundle's generated itinerary. The SVG carries its own place links. */ -}}
2
+ {{- with .Params.map -}}
3
+ {{- with $.Resources.GetMatch . -}}
4
+ <section class="place-map" aria-labelledby="place-map-heading" data-pagefind-ignore>
5
+ <h2 id="place-map-heading" class="place-map-heading">From here</h2>
6
+ <div class="place-map-drawing">{{ .Content | safeHTML }}</div>
7
+ </section>
8
+ {{- end -}}
9
+ {{- end -}}
@@ -0,0 +1,121 @@
1
+ {{- /*
2
+ Related partial.
3
+
4
+ Renders a compact "Related" block at the bottom of a single page from the
5
+ page's `related` front matter, if it carries any.
6
+
7
+ Structure in front matter:
8
+ related:
9
+ backlinks: [{ title, url, type }, ...] # pages that link here
10
+ mentions: [{ title, url, type }, ...] # pages this page links to
11
+
12
+ Rendering strategy:
13
+ - Merge both directions into a single deduped pool (direction
14
+ doesn't matter to a reader — a connection is a connection).
15
+ - Group by the referenced page's `type`.
16
+ - Emit one labelled group per type, its entries laid out as a
17
+ CSS grid (`repeat(auto-fill, minmax(14em, 1fr))`) so a wide
18
+ screen shows two or three columns and a narrow one falls back
19
+ to a single column with no media query.
20
+ - The whole block is wrapped in a bordered, tinted card so it
21
+ visually sets off the end of the article.
22
+
23
+ Silent disappear: a page with no `related`, or whose two lists are both
24
+ empty, emits nothing at all rather than an empty heading. The rows are
25
+ computed first and the <section> is rendered only when there is something
26
+ to put in it.
27
+
28
+ `return` cannot be used to bail out early here. It sets the partial's
29
+ return value; it does not discard template text the partial has already
30
+ emitted, so a guard written that way still prints the empty shell. Hence
31
+ the emptiness test wraps the markup instead of preceding it.
32
+ */ -}}
33
+
34
+ {{- /* `default dict` keeps the lookups below safe on a page with no
35
+ `related` at all, so the whole computation stays flat. */ -}}
36
+ {{- $rel := .Params.related | default dict -}}
37
+ {{- $backlinks := or $rel.backlinks slice -}}
38
+ {{- $mentions := or $rel.mentions slice -}}
39
+
40
+ {{- /* Merge both directions, deduped by URL. `union` can't hash
41
+ slices of maps, so we walk the two lists in order and dedupe
42
+ by URL manually. Mentions come first so explicit author
43
+ choices win when a page appears in both directions. */ -}}
44
+ {{- $seen := slice -}}
45
+ {{- $merged := slice -}}
46
+ {{- range $mentions -}}
47
+ {{- if not (in $seen .url) -}}
48
+ {{- $seen = $seen | append .url -}}
49
+ {{- $merged = $merged | append . -}}
50
+ {{- end -}}
51
+ {{- end -}}
52
+ {{- range $backlinks -}}
53
+ {{- if not (in $seen .url) -}}
54
+ {{- $seen = $seen | append .url -}}
55
+ {{- $merged = $merged | append . -}}
56
+ {{- end -}}
57
+ {{- end -}}
58
+
59
+ {{- /* Plural, human-readable label for each type. Falls back to
60
+ `humanize` for any type not listed here. */ -}}
61
+ {{- $labels := dict
62
+ "affiliation" "Affiliations"
63
+ "being" "Beings"
64
+ "blog-post" "Posts"
65
+ "character" "People"
66
+ "continent" "Continents"
67
+ "creature" "Creatures"
68
+ "faith" "Faiths"
69
+ "language" "Languages"
70
+ "lore" "Lore"
71
+ "organization" "Organizations"
72
+ "page" "Pages"
73
+ "pantheon" "Pantheons"
74
+ "people" "Peoples"
75
+ "polity" "Polities"
76
+ "project-page" "Projects"
77
+ "region" "Regions"
78
+ "religion" "Religions"
79
+ "settlement" "Settlements"
80
+ "site" "Places"
81
+ "world" "Worlds"
82
+ -}}
83
+
84
+ {{- /* Group refs by type, preserving alphabetical order within a
85
+ group (the input lists arrive already sorted). */ -}}
86
+ {{- $groups := dict -}}
87
+ {{- range $merged -}}
88
+ {{- $t := .type | default "page" -}}
89
+ {{- $existing := index $groups $t | default slice -}}
90
+ {{- $groups = merge $groups (dict $t ($existing | append .)) -}}
91
+ {{- end -}}
92
+
93
+ {{- /* Sort the group keys alphabetically by their rendered label
94
+ so the list reads A → Z regardless of insertion order. */ -}}
95
+ {{- $rows := slice -}}
96
+ {{- range $type, $refs := $groups -}}
97
+ {{- $label := index $labels $type | default (humanize $type) -}}
98
+ {{- $rows = $rows | append (dict "label" $label "type" $type "refs" $refs) -}}
99
+ {{- end -}}
100
+ {{- if $rows -}}
101
+ {{- $rows = sort $rows "label" "asc" -}}
102
+ {{- end -}}
103
+
104
+ {{- /* Deliberately not indented under the `if`: keeping the markup at
105
+ column 0 leaves the emitted HTML byte-identical to what pages with
106
+ `related` rendered before the guard was added. */ -}}
107
+ {{- if $rows -}}
108
+ <section class="related" aria-labelledby="related-heading" data-pagefind-ignore>
109
+ <h2 id="related-heading" class="related-heading">Related</h2>
110
+ {{- range $rows }}
111
+ <div class="related-group">
112
+ <h3 class="related-group-label">{{ .label }}</h3>
113
+ <ul class="related-group-grid">
114
+ {{- range .refs }}
115
+ <li><a href="{{ .url }}">{{ .title }}</a></li>
116
+ {{- end }}
117
+ </ul>
118
+ </div>
119
+ {{- end }}
120
+ </section>
121
+ {{ end -}}
@@ -0,0 +1,84 @@
1
+ {{- /*
2
+ The header search box, rendered only when a consumer sets `params.search`
3
+ (silent-disappear otherwise — see the README's "Search" section).
4
+
5
+ `@heroiclands/package-build`'s `package-build site-root` step writes a
6
+ Pagefind index beside the rendered pages, at `pagefind/` under the site's
7
+ own base URL, when a consumer leaves `site.search` at its default of `true`
8
+ (see that package's `docs/configuration.md`, `site.search`). Pagefind's own
9
+ UI — `pagefind-ui.js` and `pagefind-ui.css` — ships inside that generated
10
+ directory, so nothing here is bundled or pinned to a Pagefind version; the
11
+ index and the UI that reads it travel together.
12
+
13
+ Both files are referenced the same way every other theme-bundled asset is
14
+ — `relURL`, exactly as `"css/style.css" | relURL` resolves in
15
+ `baseof.html` — so a package served under a prefix (`/thalorna/`) finds
16
+ its own index rather than another package's.
17
+
18
+ A `/search/` results page would need a consumer content file at that
19
+ address, and a site is its homepage and its pages with nothing generated
20
+ between them (package-build's `docs/configuration.md`, "A site is its
21
+ homepage and its pages") — so a dedicated results page is not this
22
+ theme's to invent. Pagefind's own panel UI needs no page of its own, so
23
+ the header box opens that instead.
24
+
25
+ Context: the page (only .Site is read, so this partial can also be called
26
+ with just `.Site` in a dict).
27
+ */ -}}
28
+ {{- if .Site.Params.search }}
29
+ <div class="site-search" data-pagefind-ignore>
30
+ <button
31
+ type="button"
32
+ class="search-toggle"
33
+ aria-label="Search"
34
+ aria-expanded="false"
35
+ aria-controls="site-search-panel"
36
+ ><i class="fa-solid fa-magnifying-glass" aria-hidden="true"></i></button>
37
+ <div id="site-search-panel" class="search-panel" hidden>
38
+ <div class="search-panel-inner" id="search"></div>
39
+ </div>
40
+ </div>
41
+ <link rel="stylesheet" href="{{ "pagefind/pagefind-ui.css" | relURL }}">
42
+ <script src="{{ "pagefind/pagefind-ui.js" | relURL }}" defer></script>
43
+ <script>
44
+ (function () {
45
+ var toggle = document.querySelector(".search-toggle");
46
+ var panel = document.getElementById("site-search-panel");
47
+ if (!toggle || !panel) return;
48
+ var ui = null;
49
+
50
+ function open() {
51
+ panel.hidden = false;
52
+ toggle.setAttribute("aria-expanded", "true");
53
+ if (!ui && typeof PagefindUI !== "undefined") {
54
+ ui = new PagefindUI({
55
+ element: "#search",
56
+ showSubResults: true,
57
+ showImages: false
58
+ });
59
+ }
60
+ var input = panel.querySelector("input");
61
+ if (input) input.focus();
62
+ }
63
+
64
+ function close() {
65
+ panel.hidden = true;
66
+ toggle.setAttribute("aria-expanded", "false");
67
+ }
68
+
69
+ toggle.addEventListener("click", function () {
70
+ if (panel.hidden) { open(); } else { close(); }
71
+ });
72
+
73
+ document.addEventListener("keydown", function (e) {
74
+ if (e.key === "Escape" && !panel.hidden) close();
75
+ });
76
+
77
+ document.addEventListener("click", function (e) {
78
+ if (panel.hidden) return;
79
+ if (panel.contains(e.target) || toggle.contains(e.target)) return;
80
+ close();
81
+ });
82
+ })();
83
+ </script>
84
+ {{- end }}
@@ -0,0 +1,32 @@
1
+ {{- /*
2
+ Resolve a consumer-supplied link against the site it is rendered on.
3
+
4
+ The theme carries layout, not addresses, so every URL it renders comes from
5
+ a consuming site's configuration or front matter — and a package published
6
+ under a path prefix (`/sohl/`, `/thalorna/`) needs its own links to carry
7
+ that prefix without writing it down anywhere.
8
+
9
+ Resolution:
10
+ 1. An already-absolute URL (http://, https://, //) is returned as-is, so a
11
+ consumer can point at another host.
12
+ 2. A page fragment or query alone (#anchor, ?q=) is returned as-is.
13
+ 3. Anything else is treated as a path within this site and resolved with
14
+ `relURL`. A leading slash is trimmed first: `relURL` reads a leading
15
+ slash as "from the origin" and leaves the base path off, so trimming it
16
+ means a consumer writing the obvious "/section/" still gets a link
17
+ inside its own site when that site is served under a prefix.
18
+
19
+ Usage:
20
+ {{ partial "site-url.html" (dict "site" .Site "url" "kb/rules/") }}
21
+
22
+ Params:
23
+ site — the site context (.Site). Accepted for symmetry with cdn-url.html
24
+ and so this partial can never be tempted to read a page.
25
+ url — the address to resolve. An empty value resolves to the site root.
26
+ */ -}}
27
+ {{- $url := .url | default "" -}}
28
+ {{- $resolved := $url -}}
29
+ {{- if not (or (hasPrefix $url "http://") (hasPrefix $url "https://") (hasPrefix $url "//") (hasPrefix $url "#") (hasPrefix $url "?")) -}}
30
+ {{- $resolved = strings.TrimPrefix "/" $url | relURL -}}
31
+ {{- end -}}
32
+ {{- return $resolved -}}