@heroiclands/package-build 11.1.0 → 14.0.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.
- package/CHANGELOG.md +360 -0
- package/CONTENT.md +144 -72
- package/MIGRATING.md +71 -0
- package/bin/content-build.mjs +0 -20
- package/content-config.mjs +108 -69
- package/docs/content-format.md +50 -27
- package/engine/base-compiler.mjs +6 -1
- package/engine/content-address.mjs +29 -86
- package/engine/frontmatter-lint.mjs +74 -131
- package/engine/manifest-emit.mjs +19 -24
- package/engine/note-vocabulary.mjs +117 -1
- package/engine/retired-fields.mjs +76 -3
- package/engine/site-build.mjs +70 -78
- package/engine/site-index.mjs +20 -8
- package/engine/web-wikilinks.mjs +1 -1
- package/engine/wikilinks.mjs +1 -1
- package/package.json +1 -1
- package/types/content-config.d.mts +28 -50
- package/types/engine/content-address.d.mts +24 -43
- package/types/engine/frontmatter-lint.d.mts +2 -27
- package/types/engine/manifest-emit.d.mts +3 -9
- package/types/engine/note-vocabulary.d.mts +46 -0
- package/types/engine/retired-fields.d.mts +47 -0
- package/types/engine/site-build.d.mts +56 -31
- package/types/engine/site-index.d.mts +9 -4
|
@@ -35,6 +35,52 @@ export function hasTag(fm: object | null | undefined, tag: string): boolean;
|
|
|
35
35
|
* @returns {boolean} Whether the note carries the `draft` tag.
|
|
36
36
|
*/
|
|
37
37
|
export function isDraftNote(fm: object | null | undefined): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* What a note carrying a subType outside the address charset is told.
|
|
40
|
+
*
|
|
41
|
+
* **Why the charset holds for a subType, which reaches no address.** #206 said
|
|
42
|
+
* "the hyphen separates the segments of an address", and that was true of a
|
|
43
|
+
* subType when it shipped: `sectionOf` returned a `doc`'s subType, so the value
|
|
44
|
+
* was a URL path segment. #204 retired sections and it is not one now. The rule
|
|
45
|
+
* stays, on its own footing: a subType is a vocabulary term the whole toolchain
|
|
46
|
+
* keys on, and it is one closed set away from being an address segment again —
|
|
47
|
+
* so the reason to spell it in the address charset is that a charset holding
|
|
48
|
+
* for a type, a shortcode and a `contentPackage` but not for a subType is a
|
|
49
|
+
* rule nobody can state in a sentence.
|
|
50
|
+
*
|
|
51
|
+
* Contrast {@link typeCharsetMessage}, which keeps the address reasoning
|
|
52
|
+
* because a type genuinely is the first segment of every address.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} value - The authored `subType`.
|
|
55
|
+
* @returns {string} The message.
|
|
56
|
+
*/
|
|
57
|
+
export function subTypeCharsetMessage(value: string): string;
|
|
58
|
+
/**
|
|
59
|
+
* What a note carrying a type outside the address charset is told.
|
|
60
|
+
*
|
|
61
|
+
* @param {string} type - The authored `type`.
|
|
62
|
+
* @returns {string} The message.
|
|
63
|
+
*/
|
|
64
|
+
export function typeCharsetMessage(type: string): string;
|
|
65
|
+
/**
|
|
66
|
+
* Refuse a vocabulary that declares a type or subType outside the charset.
|
|
67
|
+
*
|
|
68
|
+
* Run over {@link NOTE_VOCABULARY} as this module loads, so a declaration that
|
|
69
|
+
* breaks the rule cannot be imported. That is stricter than a lint on purpose:
|
|
70
|
+
* a note's bad value is one author's mistake and belongs in a report, while a
|
|
71
|
+
* bad *declaration* would tell every author to write something unaddressable.
|
|
72
|
+
*
|
|
73
|
+
* The message states the reason **per key**, as {@link typeCharsetMessage} and
|
|
74
|
+
* {@link subTypeCharsetMessage} do: a type is an address segment, and a subType
|
|
75
|
+
* has not been one since #204 retired sections, so a single claim covering both
|
|
76
|
+
* would be half wrong (#210).
|
|
77
|
+
*
|
|
78
|
+
* @param {Readonly<Record<string, TypeVocabulary>>} vocabulary - The registry.
|
|
79
|
+
* @param {string} [where] - What declares it, for the message.
|
|
80
|
+
* @throws {Error} Naming every offending type and subType at once, rather than
|
|
81
|
+
* stopping at the first — a reader fixing a list wants the whole list.
|
|
82
|
+
*/
|
|
83
|
+
export function assertVocabularyCharset(vocabulary: Readonly<Record<string, TypeVocabulary>>, where?: string): void;
|
|
38
84
|
/**
|
|
39
85
|
* The `data:` keys a note type may carry.
|
|
40
86
|
*
|
|
@@ -106,6 +106,53 @@ export function assertNoAliasesField(fm: object | null | undefined, { file, absP
|
|
|
106
106
|
* @returns {boolean} Whether the retired field is declared.
|
|
107
107
|
*/
|
|
108
108
|
export function declaresRetiredAliasesField(fm: object | null | undefined): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* What a note declaring `section:` is told, in one place.
|
|
111
|
+
*
|
|
112
|
+
* Shared by the compile-time refusal and the frontmatter lint, because an
|
|
113
|
+
* author meets whichever of the two runs first and they should read the same.
|
|
114
|
+
* It names what lands a section now rather than a value to correct: no value
|
|
115
|
+
* makes declaring the field right.
|
|
116
|
+
*
|
|
117
|
+
* **What it did (#202).** It named the section a `collection` note headed,
|
|
118
|
+
* under the `collection` landing rule — the only reader it ever had, in the
|
|
119
|
+
* second branch of `landingOf` (`engine/content-address.mjs`). That rule went
|
|
120
|
+
* first, and the whole mechanism went with it (#204): a section is a Hugo
|
|
121
|
+
* directory the note format does not carry, so no note lands one and a page
|
|
122
|
+
* that introduces a type is an ordinary note addressed `doc-<type>`. Nothing
|
|
123
|
+
* else read the field, and no schema or vocabulary declared it, so left in
|
|
124
|
+
* place it would be ignored in silence — the note saying one thing and the
|
|
125
|
+
* build doing another.
|
|
126
|
+
*
|
|
127
|
+
* @param {string} [file] - The note's path, named in the message. Omit it where
|
|
128
|
+
* the caller emits through a diagnostic, whose locator already starts the
|
|
129
|
+
* line — repeating it prints the path twice.
|
|
130
|
+
* @returns {string} The message, unpunctuated at the end as a finding is.
|
|
131
|
+
*/
|
|
132
|
+
export function sectionRetiredMessage(file?: string): string;
|
|
133
|
+
/**
|
|
134
|
+
* Refuse a note that declares `section:` at all.
|
|
135
|
+
*
|
|
136
|
+
* Presence is the whole test, as it is for `draft:` and `aliases:`: an empty
|
|
137
|
+
* value reads as "this note heads a section and names none", a statement about
|
|
138
|
+
* a rule that no longer exists.
|
|
139
|
+
*
|
|
140
|
+
* @param {object|null|undefined} fm - Parsed frontmatter, or nothing when it
|
|
141
|
+
* could not be parsed.
|
|
142
|
+
* @param {object} [options] - Options.
|
|
143
|
+
* @param {string} [options.file] - The note's path, named in the message. Omit
|
|
144
|
+
* it where the caller emits through a diagnostic, which puts the locator at
|
|
145
|
+
* the start of the line already — repeating it prints the path twice.
|
|
146
|
+
* @param {string} [options.absPath] - The note's file on disk, read only on the
|
|
147
|
+
* failing path to locate the offending line and column. The position rides on
|
|
148
|
+
* the thrown error as `position`, for a caller that emits a diagnostic.
|
|
149
|
+
* @returns {void}
|
|
150
|
+
* @throws {Error} When the note declares the field.
|
|
151
|
+
*/
|
|
152
|
+
export function assertNoSectionField(fm: object | null | undefined, { file, absPath }?: {
|
|
153
|
+
file?: string | undefined;
|
|
154
|
+
absPath?: string | undefined;
|
|
155
|
+
}): void;
|
|
109
156
|
/**
|
|
110
157
|
* A frontmatter key's position in a note's file, or nothing.
|
|
111
158
|
*
|
|
@@ -196,12 +196,10 @@ export function sectionFrontmatter(meta: object): object;
|
|
|
196
196
|
* redirects of its own.
|
|
197
197
|
*
|
|
198
198
|
* A content page states its own **`url`**, which is its address rather than its
|
|
199
|
-
* path (#181).
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
* lookup. So the directory stays and the address is stated, and the two are
|
|
204
|
-
* free to differ.
|
|
199
|
+
* path (#181). It is written flat under the content mount (#204), so Hugo would
|
|
200
|
+
* otherwise publish it at `<mount><type>-<shortcode>/` rather than at the
|
|
201
|
+
* package-wide address the link manifest records — the same address, one
|
|
202
|
+
* segment too deep. So the address is stated and the mount does not reach it.
|
|
205
203
|
*
|
|
206
204
|
* A content page carries the package the build **derived** (#65). No note
|
|
207
205
|
* declares one — `package:` is retired (#56) — so the note's frontmatter alone
|
|
@@ -213,24 +211,34 @@ export function sectionFrontmatter(meta: object): object;
|
|
|
213
211
|
* self-describing and makes sweeping the field out of a content tree
|
|
214
212
|
* output-preserving for a site as it already is for the packs.
|
|
215
213
|
*
|
|
214
|
+
* A **tree** page is the one that still reads `readmeSections`: a `trees` entry
|
|
215
|
+
* keeps its source layout below a named section, so its own `README` is that
|
|
216
|
+
* section's landing and takes the title and hero the section declares.
|
|
217
|
+
*
|
|
216
218
|
* @param {object} page - The page.
|
|
217
|
-
* @param {object} options - `{
|
|
219
|
+
* @param {object} options - `{ readmeSections, decorate }`.
|
|
218
220
|
* @returns {object} The frontmatter to write.
|
|
219
221
|
*/
|
|
220
222
|
export function pageFrontmatter(page: object, { readmeSections, decorate }: object): object;
|
|
221
223
|
/**
|
|
222
224
|
* Where a page is written, relative to the output root.
|
|
223
225
|
*
|
|
224
|
-
* **
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
* Hugo
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
* The
|
|
232
|
-
* two
|
|
233
|
-
*
|
|
226
|
+
* **Flat, under the mount, named by its address** (#204). A content page's URL
|
|
227
|
+
* is its address — `/<package>/<type>-<shortcode>/` — and the file is now named
|
|
228
|
+
* the same way, so the two agree. It used to be filed into `<section>/` so that
|
|
229
|
+
* Hugo would read a section off its path; a section appears in no address, and
|
|
230
|
+
* a directory chosen only to satisfy a rendering engine's idea of what a
|
|
231
|
+
* section is has no business in the note format.
|
|
232
|
+
*
|
|
233
|
+
* The name is the *whole* address rather than a section-relative half of it, so
|
|
234
|
+
* two types cannot fight over one file: a `doc` note's `subType` may be spelled
|
|
235
|
+
* the same as another note's `type`, and `doc-gear.md` and `weapongear-gear.md`
|
|
236
|
+
* are distinct whatever the sections used to be.
|
|
237
|
+
*
|
|
238
|
+
* **A `trees` entry is the exception, and always was.** Those pages preserve
|
|
239
|
+
* their source layout below a named section — they are a book with chapters,
|
|
240
|
+
* addressed by their path — so a `README` there is still its directory's
|
|
241
|
+
* `_index.md`.
|
|
234
242
|
*/
|
|
235
243
|
export function pageDestination(page: any): string;
|
|
236
244
|
/**
|
|
@@ -259,26 +267,43 @@ export function renderPages(pages: object[], options: object): {
|
|
|
259
267
|
wikiErrors: object[];
|
|
260
268
|
};
|
|
261
269
|
/**
|
|
262
|
-
* Writes the
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
* is
|
|
266
|
-
*
|
|
270
|
+
* Writes the Hugo sections a published tree declares.
|
|
271
|
+
*
|
|
272
|
+
* **This is where a section lives now, and the only place** (#204). A content
|
|
273
|
+
* note carries none: it is addressed by `(type, shortcode)` and emitted flat
|
|
274
|
+
* under the mount, so nothing a page does creates a directory. A site that wants
|
|
275
|
+
* `/<package>/<prefix><section>/` to answer — with a title, a hero, and whatever
|
|
276
|
+
* listing its layout builds — says so here, in configuration, and this writes
|
|
277
|
+
* the `_index.md` that makes Hugo agree it is a section.
|
|
278
|
+
*
|
|
279
|
+
* Three jobs, all of them Hugo's directory semantics rather than the note
|
|
280
|
+
* format's:
|
|
281
|
+
*
|
|
282
|
+
* - **The mount's own landing**, so `/<package>/<prefix>` is a page rather than
|
|
283
|
+
* a directory listing. It carries a `type` of its own: Hugo's template lookup
|
|
284
|
+
* walks up a page's path, so an untyped landing template at the mount would
|
|
285
|
+
* also serve every section below it that has none.
|
|
267
286
|
* - **Declared sections** get a titled `_index.md` with their hero, so a landing
|
|
268
287
|
* matches the card that links to it instead of showing Hugo's auto-humanised
|
|
269
|
-
* directory name. The body is empty, which lets the theme
|
|
270
|
-
*
|
|
271
|
-
* - **Every other section directly under the mount** gets a bare `_index.md`,
|
|
288
|
+
* directory name. The body is empty, which lets the theme decide what to list.
|
|
289
|
+
* - **Every other directory directly under the mount** gets a bare `_index.md`,
|
|
272
290
|
* or its own address publishes nothing. Hugo generates a section page
|
|
273
291
|
* automatically only for a *top-level* content directory; below that, a
|
|
274
|
-
* directory without an `_index.md` is not a section, so its URL 404s while
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
*
|
|
292
|
+
* directory without an `_index.md` is not a section, so its URL 404s while its
|
|
293
|
+
* children publish normally. With content pages flat, what that reaches is a
|
|
294
|
+
* `trees` entry's directory — the one thing left below the mount that a note
|
|
295
|
+
* creates.
|
|
296
|
+
*
|
|
297
|
+
* **A section listing is not a page listing any more.** A layout that reads
|
|
298
|
+
* `.Pages` off a section it declares here will find nothing, because no file is
|
|
299
|
+
* filed into it; one that queries `site.RegularPages` by `Params.type` — which
|
|
300
|
+
* is how `sohl`'s eleven catalog layouts already work — is unaffected. That is a
|
|
301
|
+
* consumer's layout to choose, and it is stated here because the choice is no
|
|
302
|
+
* longer free.
|
|
278
303
|
*
|
|
279
304
|
* Scoped to one level on purpose. A directory further down was not a section
|
|
280
|
-
* before
|
|
281
|
-
*
|
|
305
|
+
* before either, and giving it one here would silently re-scope the prev/next
|
|
306
|
+
* navigation of every page inside it.
|
|
282
307
|
*
|
|
283
308
|
* @param {string} outRoot - The mount directory.
|
|
284
309
|
* @param {object} options - `{ sections, landing, sectionTitle }`.
|
|
@@ -73,9 +73,13 @@ export type SiteEntry = {
|
|
|
73
73
|
*/
|
|
74
74
|
slug: string;
|
|
75
75
|
/**
|
|
76
|
-
*
|
|
76
|
+
* The Hugo section a **tree** page is filed under, and
|
|
77
|
+
* the first segment of the `<sec>/<slug>` address it
|
|
78
|
+
* is reachable by. A content page has none: it is
|
|
79
|
+
* addressed by `(type, shortcode)` and emitted flat
|
|
80
|
+
* (#204).
|
|
77
81
|
*/
|
|
78
|
-
sec
|
|
82
|
+
sec?: string | undefined;
|
|
79
83
|
/**
|
|
80
84
|
* Source file's basename, e.g. `Climbing.md`.
|
|
81
85
|
*/
|
|
@@ -85,9 +89,10 @@ export type SiteEntry = {
|
|
|
85
89
|
*/
|
|
86
90
|
url: string;
|
|
87
91
|
/**
|
|
88
|
-
* Whether
|
|
92
|
+
* Whether a tree page is its directory's
|
|
93
|
+
* landing.
|
|
89
94
|
*/
|
|
90
|
-
isReadme
|
|
95
|
+
isReadme?: boolean | undefined;
|
|
91
96
|
};
|
|
92
97
|
/**
|
|
93
98
|
* The resolved index and everything a wikilink resolver reads beside it.
|