@dogsbay/format-hugo 0.2.0-beta.101

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.
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Hugo builtin + Docsy theme shortcodes.
3
+ *
4
+ * Every mapping here is evidence-backed: the counts in the comments are
5
+ * measured occurrences in `kubernetes/website/content/en`. A shortcode whose
6
+ * semantics could not be verified from real content is deliberately NOT mapped
7
+ * — an unmapped shortcode is preserved verbatim with a ledger entry, which is
8
+ * honest, whereas a guessed mapping silently misrepresents the source.
9
+ */
10
+ import { type ShortcodeRegistry } from "./registry.js";
11
+ export declare const BUILTIN_SHORTCODES: ShortcodeRegistry;
12
+ //# sourceMappingURL=builtins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builtins.d.ts","sourceRoot":"","sources":["../src/builtins.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAA6B,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAgBlF,eAAO,MAAM,kBAAkB,EAAE,iBAuMhC,CAAC"}
@@ -0,0 +1,207 @@
1
+ /**
2
+ * Hugo builtin + Docsy theme shortcodes.
3
+ *
4
+ * Every mapping here is evidence-backed: the counts in the comments are
5
+ * measured occurrences in `kubernetes/website/content/en`. A shortcode whose
6
+ * semantics could not be verified from real content is deliberately NOT mapped
7
+ * — an unmapped shortcode is preserved verbatim with a ledger entry, which is
8
+ * honest, whereas a guessed mapping silently misrepresents the source.
9
+ */
10
+ import { arg, attrBlock, directive } from "./registry.js";
11
+ import { lookupParam } from "./config.js";
12
+ import { looksLikeFile } from "./resolve.js";
13
+ /** Docsy `alert` colours → Dogsbay callout types. */
14
+ const ALERT_COLOURS = {
15
+ primary: "info",
16
+ secondary: "note",
17
+ info: "info",
18
+ success: "success",
19
+ warning: "warning",
20
+ danger: "danger",
21
+ dark: "note",
22
+ light: "note",
23
+ };
24
+ export const BUILTIN_SHORTCODES = {
25
+ // ── Hugo builtins ───────────────────────────────────────
26
+ //
27
+ // `{{< highlight go "linenos=table" >}}` — a code block with a language and
28
+ // Chroma options. 29 uses. The options are Chroma-specific and have no
29
+ // Dogsbay equivalent, so they are recorded rather than guessed at.
30
+ highlight: (node, ctx) => {
31
+ const lang = node.args.positional[0] ?? "";
32
+ const options = node.args.positional.slice(1).join(" ");
33
+ if (options) {
34
+ ctx.report({
35
+ shortcode: "highlight",
36
+ action: "degraded",
37
+ note: `Chroma options dropped (${options}) — no equivalent outside Hugo`,
38
+ line: node.line,
39
+ });
40
+ }
41
+ const body = node.inner.replace(/^\n+|\n+$/g, "");
42
+ const fence = "`".repeat(Math.max(3, ...[...body.matchAll(/`{3,}/g)].map((m) => m[0].length + 1)));
43
+ return `${fence}${lang}\n${body}\n${fence}`;
44
+ },
45
+ // `{{< figure src="x.png" alt="…" caption="…" >}}` — 232 uses.
46
+ figure: (node) => {
47
+ const src = arg(node.args, "src") ?? "";
48
+ const alt = node.args.named.alt ?? node.args.named.title ?? "";
49
+ const caption = node.args.named.caption;
50
+ const image = `![${alt}](${src})`;
51
+ return caption ? directive("figure", attrBlock({ caption }), image) : image;
52
+ },
53
+ // `{{< youtube dQw4w9WgXcQ >}}` — 15 uses. `id=` is also accepted.
54
+ youtube: (node) => {
55
+ const id = arg(node.args, "id") ?? "";
56
+ return id ? directive("youtube", attrBlock({ id }), "") : null;
57
+ },
58
+ // `{{< param "version" >}}` / `{{< param version.next >}}` — 120 uses.
59
+ // Substitutes from site params. An unresolved param must be RECORDED, never
60
+ // written out as the string "undefined".
61
+ param: (node, ctx) => {
62
+ const key = arg(node.args, "name") ?? "";
63
+ const value = lookupParam(ctx.config.params, key);
64
+ if (value === undefined) {
65
+ ctx.report({
66
+ shortcode: "param",
67
+ action: "degraded",
68
+ note: `site param "${key}" is not defined in the Hugo config — substituted as empty`,
69
+ line: node.line,
70
+ });
71
+ return "";
72
+ }
73
+ return value;
74
+ },
75
+ // `{{< ref "docs/concepts/_index.md" >}}` — 2570 uses, by far the most
76
+ // common shortcode in the corpus. It resolves a page reference to its URL.
77
+ // Unresolved, every one of these becomes a broken link, so the resolver is
78
+ // wired from the page set rather than guessed from the path.
79
+ ref: (node, ctx) => {
80
+ const target = arg(node.args, "path") ?? "";
81
+ const href = ctx.resolveRef?.(target, ctx.file);
82
+ if (href !== undefined)
83
+ return href;
84
+ ctx.report({
85
+ shortcode: "ref",
86
+ action: "degraded",
87
+ note: `could not resolve reference "${target}" — emitted as a relative path`,
88
+ line: node.line,
89
+ });
90
+ // Better a path than nothing: the link still points somewhere plausible
91
+ // and a link checker can find it.
92
+ return `/${target.replace(/^\//, "").replace(/(?:\/_?index)?\.md$/, "")}`;
93
+ },
94
+ // `{{< relref "other.md" >}}` — 13 uses. Same resolution, relative result.
95
+ relref: (node, ctx) => {
96
+ const target = arg(node.args, "path") ?? "";
97
+ const href = ctx.resolveRef?.(target, ctx.file);
98
+ if (href !== undefined)
99
+ return href;
100
+ ctx.report({
101
+ shortcode: "relref",
102
+ action: "degraded",
103
+ note: `could not resolve reference "${target}" — emitted as a relative path`,
104
+ line: node.line,
105
+ });
106
+ return target.replace(/(?:\/_?index)?\.md$/, "");
107
+ },
108
+ // ── Callouts ────────────────────────────────────────────
109
+ //
110
+ // Hugo/Docsy sites all grow the same three, and Kubernetes uses them 1,071
111
+ // times between them. The body may be markdown (`{{% note %}}`) or raw
112
+ // (`{{< note >}}`); either way it is content and gets translated.
113
+ note: (node, ctx) => directive("note", "", ctx.translate(node.inner)),
114
+ caution: (node, ctx) => directive("caution", "", ctx.translate(node.inner)),
115
+ warning: (node, ctx) => directive("warning", "", ctx.translate(node.inner)),
116
+ // Docsy's own callout. 91 uses. `color=` selects the variant and `title=`
117
+ // is a heading on the box.
118
+ alert: (node, ctx) => {
119
+ const colour = (node.args.named.color ?? "").toLowerCase();
120
+ const type = ALERT_COLOURS[colour] ?? "note";
121
+ if (colour && !ALERT_COLOURS[colour]) {
122
+ ctx.report({
123
+ shortcode: "alert",
124
+ action: "degraded",
125
+ note: `unknown alert colour "${colour}" → :::note`,
126
+ line: node.line,
127
+ });
128
+ }
129
+ return directive(type, attrBlock({ title: node.args.named.title }), ctx.translate(node.inner));
130
+ },
131
+ // Docsy `pageinfo` — a page-level banner. Same shape as an alert.
132
+ pageinfo: (node, ctx) => directive(ALERT_COLOURS[(node.args.named.color ?? "").toLowerCase()] ?? "info", "", ctx.translate(node.inner)),
133
+ // ── Tabs ────────────────────────────────────────────────
134
+ //
135
+ // `{{< tabs name="x" >}}` wrapping `{{% tab name="Linux" %}}`. 117 groups,
136
+ // 287 tabs. Note the delimiter mix: the wrapper is angle, the tabs are
137
+ // percent, which is exactly why the scanner has to handle both.
138
+ tabs: (node, ctx) => directive("tabs", "", ctx.translate(node.inner)),
139
+ tab: (node, ctx) => {
140
+ const title = arg(node.args, "name", "header", "title") ?? "";
141
+ // `{{< tab name="x" include="file.md" />}}` — the kubeadm reference pages
142
+ // use this 118 times to pull in generated content.
143
+ // `include=` is not always a path: `{{< feature-gate-table include="alpha,beta" >}}`
144
+ // uses the same attribute name as a FILTER, and treating that as a file
145
+ // produced a guaranteed-failing read plus a misleading ledger entry.
146
+ const include = node.args.named.include;
147
+ if (looksLikeFile(include)) {
148
+ const content = ctx.readContentFile?.(include, ctx.file);
149
+ if (content !== undefined) {
150
+ return directive("tab", attrBlock({ title }), ctx.translate(content));
151
+ }
152
+ ctx.report({
153
+ shortcode: "tab",
154
+ action: "degraded",
155
+ note: `could not read included file "${include}" — tab is empty`,
156
+ line: node.line,
157
+ });
158
+ return directive("tab", attrBlock({ title }), "");
159
+ }
160
+ return directive("tab", attrBlock({ title }), ctx.translate(node.inner));
161
+ },
162
+ // Docsy's newer tab syntax.
163
+ tabpane: (node, ctx) => directive("tabs", "", ctx.translate(node.inner)),
164
+ "tab-pane": (node, ctx) => directive("tab", attrBlock({ title: arg(node.args, "header", "title", "name") }), ctx.translate(node.inner)),
165
+ // ── Other block constructs ──────────────────────────────
166
+ //
167
+ // 53 uses. A mermaid diagram is a code block with a `mermaid` language
168
+ // everywhere outside Hugo.
169
+ mermaid: (node) => {
170
+ const body = node.inner.replace(/^\n+|\n+$/g, "");
171
+ return `\`\`\`mermaid\n${body}\n\`\`\``;
172
+ },
173
+ // 59 uses. `{{< table caption="…" >}}` wraps a markdown table to caption it.
174
+ table: (node, ctx) => {
175
+ const caption = node.args.named.caption;
176
+ const body = ctx.translate(node.inner).replace(/^\n+|\n+$/g, "");
177
+ // Dogsbay-MD captions a table with a trailing `{caption}` line.
178
+ return caption ? `${body}\n{${caption}}` : body;
179
+ },
180
+ // `{{< include "file.md" >}}` — 171 uses. Pulls in another content file.
181
+ include: (node, ctx) => {
182
+ const target = arg(node.args, "file", "path") ?? "";
183
+ const content = ctx.readContentFile?.(target, ctx.file);
184
+ if (content === undefined) {
185
+ ctx.report({
186
+ shortcode: "include",
187
+ action: "degraded",
188
+ note: `could not read included file "${target}"`,
189
+ line: node.line,
190
+ });
191
+ return "";
192
+ }
193
+ return ctx.translate(content);
194
+ },
195
+ // 12 uses. An author note that never renders — dropping it is correct, and
196
+ // recording the drop is what makes it not-silent.
197
+ comment: (node, ctx) => {
198
+ ctx.report({
199
+ shortcode: "comment",
200
+ action: "stripped",
201
+ note: "author comment — not rendered by Hugo either",
202
+ line: node.line,
203
+ });
204
+ return null;
205
+ },
206
+ };
207
+ //# sourceMappingURL=builtins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builtins.js","sourceRoot":"","sources":["../src/builtins.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAA0B,MAAM,eAAe,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,qDAAqD;AACrD,MAAM,aAAa,GAA2B;IAC5C,OAAO,EAAE,MAAM;IACf,SAAS,EAAE,MAAM;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ist/cli.d.ts ADDED
@@ -0,0 +1,33 @@
1
+ import type { FormatPlugin, ExportPage, NavItem } from "@dogsbay/types";
2
+ import type { HugoLedgerEntry } from "./registry.js";
3
+ export interface HugoImportResult {
4
+ pages: ExportPage[];
5
+ nav: NavItem[];
6
+ /** What could not be carried across, per shortcode. */
7
+ ledger: HugoLedgerEntry[];
8
+ /** Site title from the Hugo config, when it declared one. */
9
+ siteTitle?: string;
10
+ /** Languages the site declares — the choices for `--lang`. */
11
+ languages: string[];
12
+ /**
13
+ * Absolute directory the page slugs are relative to: the content dir,
14
+ * narrowed by `--lang` and `--section`. Recomputing it from the config
15
+ * alone drops both narrowings and resolves includes to the wrong file.
16
+ */
17
+ contentRoot: string;
18
+ /** Docs roots to mirror non-`.md` assets from (dir + slug prefix). */
19
+ assetRoots: {
20
+ dir: string;
21
+ prefix: string;
22
+ }[];
23
+ }
24
+ export declare function importHugo(source: string, opts: Record<string, unknown>): Promise<HugoImportResult>;
25
+ /** Group the ledger for a human-readable report. */
26
+ export declare function summariseHugoLedger(ledger: HugoLedgerEntry[]): Array<{
27
+ shortcode: string;
28
+ action: string;
29
+ count: number;
30
+ note?: string;
31
+ }>;
32
+ export declare const plugin: FormatPlugin;
33
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAMxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,GAAG,EAAE,OAAO,EAAE,CAAC;IACf,uDAAuD;IACvD,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8DAA8D;IAC9D,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,sEAAsE;IACtE,UAAU,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC/C;AAED,wBAAsB,UAAU,CAC9B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAAC,gBAAgB,CAAC,CA2I3B;AAED,oDAAoD;AACpD,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,eAAe,EAAE,GACxB,KAAK,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAS5E;AAED,eAAO,MAAM,MAAM,EAAE,YAyBpB,CAAC"}
package/dist/cli.js ADDED
@@ -0,0 +1,190 @@
1
+ /**
2
+ * FormatPlugin for Hugo as a source format.
3
+ *
4
+ * Orchestrates: detect site → load config → collect pages → build nav and the
5
+ * ref resolver from the page set → translate each page → parse to TreeNode.
6
+ *
7
+ * The ref resolver has to exist BEFORE any page is translated, because
8
+ * `{{< ref >}}` is the most common shortcode in a real Hugo corpus (2,570 uses
9
+ * on kubernetes/website) and resolving it needs the whole page set. That is
10
+ * why this is two passes, not one.
11
+ */
12
+ import { existsSync, readFileSync } from "node:fs";
13
+ import { join, resolve } from "node:path";
14
+ import { dogsbayMdToTree, extractHeadings } from "@dogsbay/format-dogsbay-md";
15
+ import { detectHugo, loadHugoConfig, contentDirFor } from "./config.js";
16
+ import { collectHugoPages, buildHugoNav, makeRefResolver, splitFrontmatter } from "./nav.js";
17
+ import { makeContentResolver } from "./resolve.js";
18
+ import { translateHugo } from "./translate.js";
19
+ export async function importHugo(source, opts) {
20
+ if (!existsSync(source)) {
21
+ throw new Error(`Source directory not found: ${source}`);
22
+ }
23
+ const config = loadHugoConfig(source);
24
+ if (config.parseErrors.length > 0) {
25
+ // Not fatal, but never silent: params feed `{{< param >}}` and
26
+ // `{{< skew >}}`, so a config we fell back on turns those into nothing.
27
+ for (const e of config.parseErrors) {
28
+ console.warn(` warning: could not parse ${e.file} — ${e.message}`);
29
+ }
30
+ }
31
+ const lang = typeof opts.lang === "string" ? opts.lang : undefined;
32
+ const section = typeof opts.section === "string" ? opts.section.replace(/^\/+|\/+$/g, "") : undefined;
33
+ const hrefPrefix = typeof opts.hrefPrefix === "string" ? opts.hrefPrefix : "";
34
+ const langRoot = resolve(source, contentDirFor(config, lang));
35
+ // `--section docs` imports one subtree. On a site like kubernetes the blog
36
+ // is ~1,500 dated pages that Hugo renders through a SEPARATE layout, so
37
+ // pulling everything into one docs sidebar is faithful to the file tree and
38
+ // useless to a reader.
39
+ const contentRoot = section ? resolve(langRoot, section) : langRoot;
40
+ if (!existsSync(contentRoot)) {
41
+ const choices = config.languages.map((l) => l.code).join(", ");
42
+ throw new Error(`Content directory not found: ${contentRoot}` +
43
+ (section ? `\n(--section ${section} resolved against ${langRoot})` : "") +
44
+ (choices ? `\nDeclared languages: ${choices}` : ""));
45
+ }
46
+ // PASS 1 — the page set. Nav and ref resolution both need all of it before
47
+ // any page can be translated.
48
+ const hugoPages = collectHugoPages(contentRoot, config.permalinks, config.sectionPermalinks);
49
+ const nav = buildHugoNav(hugoPages, hrefPrefix);
50
+ const resolveRef = makeRefResolver(hugoPages, hrefPrefix);
51
+ const readContentFile = makeContentResolver({ contentRoot });
52
+ // PASS 2 — translate and parse.
53
+ const ledger = [];
54
+ const pages = [];
55
+ const seen = new Set();
56
+ for (const page of hugoPages) {
57
+ if (page.hidden && opts.includeDrafts !== true)
58
+ continue;
59
+ // An `.html` content page is a Go template, not markdown. It is still a
60
+ // page — it has a title, a slug and a place in the nav — so it is emitted
61
+ // as a stub and RECORDED, rather than skipped. Skipping left kubernetes
62
+ // with no home page at all (its home is `content/en/_index.html`) and the
63
+ // site root redirecting to whatever sorted first.
64
+ if (page.unrenderable) {
65
+ ledger.push({
66
+ shortcode: "(page)",
67
+ action: "degraded",
68
+ note: `${page.rel} is an HTML content page (Go template, no markdown) — emitted as a titled stub`,
69
+ line: 0,
70
+ file: page.rel,
71
+ });
72
+ pages.push({
73
+ slug: page.slug,
74
+ title: page.title,
75
+ tree: [],
76
+ headings: [],
77
+ frontmatter: page.frontmatter,
78
+ });
79
+ seen.add(page.slug);
80
+ continue;
81
+ }
82
+ const source_ = readFileSync(page.file, "utf-8");
83
+ const { body } = splitFrontmatter(source_);
84
+ const { markdown, ledger: entries } = translateHugo(body, {
85
+ config,
86
+ file: page.rel,
87
+ resolveRef,
88
+ readContentFile,
89
+ kubernetes: opts.kubernetes !== false,
90
+ });
91
+ ledger.push(...entries);
92
+ let tree;
93
+ try {
94
+ ({ tree } = dogsbayMdToTree(markdown));
95
+ }
96
+ catch (err) {
97
+ // A page that will not parse must be REPORTED, not dropped: it is the
98
+ // one failure mode a page count cannot show.
99
+ ledger.push({
100
+ shortcode: "(page)",
101
+ action: "degraded",
102
+ note: `could not parse the translated markdown — ${err instanceof Error ? err.message : String(err)}`,
103
+ line: 0,
104
+ file: page.rel,
105
+ });
106
+ continue;
107
+ }
108
+ // Two source files can resolve to one slug (a `url:` override colliding
109
+ // with a real path). Silently overwriting one with the other loses a page.
110
+ let slug = page.slug;
111
+ if (seen.has(slug)) {
112
+ let n = 2;
113
+ while (seen.has(`${slug}-${n}`))
114
+ n++;
115
+ ledger.push({
116
+ shortcode: "(page)",
117
+ action: "degraded",
118
+ note: `slug "${slug}" is claimed by more than one source file — emitted as "${slug}-${n}"`,
119
+ line: 0,
120
+ file: page.rel,
121
+ });
122
+ slug = `${slug}-${n}`;
123
+ }
124
+ seen.add(slug);
125
+ pages.push({
126
+ slug,
127
+ title: page.title,
128
+ tree,
129
+ headings: extractHeadings(tree),
130
+ frontmatter: page.frontmatter,
131
+ // Include fragments are emitted so their text is not lost, but marked so
132
+ // the CLI writes them as include targets rather than routable pages.
133
+ ...(page.fragment ? { fragment: true } : {}),
134
+ });
135
+ }
136
+ return {
137
+ pages,
138
+ nav,
139
+ ledger,
140
+ // The root slugs are relative to — `content/`, narrowed by `--lang` and
141
+ // `--section`. Callers must use THIS, not recompute it: an include
142
+ // resolved against a recomputed `content/` while the pages came from
143
+ // `content/docs/` silently found a DIFFERENT file of the same name.
144
+ contentRoot,
145
+ siteTitle: config.title,
146
+ languages: config.languages.map((l) => l.code),
147
+ assetRoots: [{ dir: contentRoot, prefix: "" }],
148
+ };
149
+ }
150
+ /** Group the ledger for a human-readable report. */
151
+ export function summariseHugoLedger(ledger) {
152
+ const rows = new Map();
153
+ for (const entry of ledger) {
154
+ const key = `${entry.shortcode}\t${entry.action}`;
155
+ const row = rows.get(key);
156
+ if (row)
157
+ row.count++;
158
+ else
159
+ rows.set(key, { shortcode: entry.shortcode, action: entry.action, count: 1, note: entry.note });
160
+ }
161
+ return [...rows.values()].sort((a, b) => b.count - a.count);
162
+ }
163
+ export const plugin = {
164
+ name: "hugo",
165
+ canImport: true,
166
+ canExport: false,
167
+ detectSource: (path) => {
168
+ if (!detectHugo(path))
169
+ return false;
170
+ // A Hugo site must also have content; a bare `hugo.toml` in a tools repo
171
+ // is not a docs corpus.
172
+ const config = loadHugoConfig(path);
173
+ return existsSync(join(path, config.contentDir)) || existsSync(join(path, "content"));
174
+ },
175
+ importOptions: [
176
+ { flags: "--lang <code>", description: "language directory to import (multilingual sites)" },
177
+ { flags: "--section <path>", description: "import only this subtree, e.g. docs" },
178
+ { flags: "--include-drafts", description: "import pages marked draft/headless" },
179
+ { flags: "--no-kubernetes", description: "disable the kubernetes.io shortcode layer" },
180
+ ],
181
+ async import(source, opts) {
182
+ const result = await importHugo(source, opts);
183
+ return {
184
+ pages: result.pages,
185
+ nav: result.nav,
186
+ contentRoot: result.contentRoot,
187
+ };
188
+ },
189
+ };
190
+ //# sourceMappingURL=cli.js.map
@@ -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W,EAAE,MAAM,CAAC,WAAW;SAChC,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -0,0 +1,72 @@
1
+ export interface HugoLanguage {
2
+ code: string;
3
+ /** Content directory for this language, relative to the site root. */
4
+ contentDir: string;
5
+ title?: string;
6
+ weight?: number;
7
+ }
8
+ export interface HugoConfig {
9
+ title?: string;
10
+ baseURL?: string;
11
+ /** Default content directory, relative to the site root. */
12
+ contentDir: string;
13
+ /** Site params — the substitution source for `{{< param >}}` / `{{< skew >}}`. */
14
+ params: Record<string, unknown>;
15
+ /** Declared languages, empty when the site is monolingual. */
16
+ languages: HugoLanguage[];
17
+ /** Theme names, in order. `docsy` here is what selects the Docsy mappings. */
18
+ themes: string[];
19
+ /**
20
+ * `[permalinks]` — per-section URL patterns.
21
+ *
22
+ * NOT cosmetic. kubernetes maps `blog = "/:section/:year/:month/:day/:slug/"`,
23
+ * so `blog/_posts/2018/coredns-ga.md` is served at
24
+ * `/blog/2018/07/10/coredns-ga/` and the `_posts/2018` directories never
25
+ * appear in the URL at all. Ignoring this produced slugs containing
26
+ * `_posts`, which Docusaurus then refused entirely — it reserves a leading
27
+ * `_` for partials — and the build failed on 400+ "sidebar document ids do
28
+ * not exist".
29
+ */
30
+ permalinks: Record<string, string>;
31
+ /**
32
+ * `[permalinks.section]` — patterns for SECTION pages (`_index.md`).
33
+ *
34
+ * Kept separate because Hugo keeps them separate, and conflating them is a
35
+ * real bug: kubernetes declares only `[permalinks.page]`, so applying its
36
+ * blog pattern to `blog/_index.md` turned the section's own slug into
37
+ * `blog/blog` and dropped "Blog" to the bottom of the nav.
38
+ */
39
+ sectionPermalinks: Record<string, string>;
40
+ /** Files the config was assembled from, for diagnostics. */
41
+ sources: string[];
42
+ /**
43
+ * Configs that could not be parsed, with the reason.
44
+ *
45
+ * This must be SURFACED, not swallowed: `{{< param >}}` and `{{< skew >}}`
46
+ * substitute from `[params]`, so a config we silently fall back on turns
47
+ * hundreds of content substitutions into nothing while the import reports
48
+ * success.
49
+ */
50
+ parseErrors: Array<{
51
+ file: string;
52
+ message: string;
53
+ }>;
54
+ }
55
+ /** Detect whether a directory looks like a Hugo site. */
56
+ export declare function detectHugo(dir: string): boolean;
57
+ export declare function loadHugoConfig(dir: string): HugoConfig;
58
+ /**
59
+ * Resolve a dotted param path against the site params, the way
60
+ * `{{< param "version.next" >}}` does. Returns undefined when absent, so the
61
+ * caller can record the unresolved reference rather than emitting "undefined".
62
+ */
63
+ export declare function lookupParam(params: Record<string, unknown>, path: string): string | undefined;
64
+ /**
65
+ * The content directory to import for a given language.
66
+ *
67
+ * A multilingual Hugo site keeps one directory per language
68
+ * (`content/en`, `content/ja`, …). Kubernetes declares 18. One language per
69
+ * import run: mixing them produces a page set with colliding slugs.
70
+ */
71
+ export declare function contentDirFor(config: HugoConfig, lang?: string): string;
72
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,sEAAsE;IACtE,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4DAA4D;IAC5D,UAAU,EAAE,MAAM,CAAC;IACnB,kFAAkF;IAClF,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,8DAA8D;IAC9D,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,8EAA8E;IAC9E,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;;;;;;;;;OAUG;IACH,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC;;;;;;;OAOG;IACH,iBAAiB,E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