clean-jsdoc-theme 5.0.0-alpha.3 → 5.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/README.md CHANGED
@@ -42,8 +42,13 @@ of every page for LLMs. No CSS or build config required to get started.
42
42
  [Pagefind](https://pagefind.app/) full-text index.
43
43
  - **Guides + API in one site** — hand-written Markdown guides and the
44
44
  auto-generated reference share one sidebar and one search.
45
+ - **Localization built in** — declare your locales and the `clean-jsdoc` CLI
46
+ builds one static site per language (translated UI, API descriptions, and
47
+ prose) with a header language switcher, per-language fonts, and `hreflang`.
45
48
  - **LLM-friendly** — every page ships a clean companion `.md`, plus a
46
- copy-page button to hand any page to Claude / ChatGPT / Perplexity.
49
+ copy-page button to hand any page to Claude / ChatGPT / Perplexity. A
50
+ downloadable [skill](https://ankdev.me/clean-jsdoc-theme/theme/llm-skill) turns
51
+ any coding assistant into a setup expert.
47
52
  - **Polished by default** — light/dark OKLCH themes, Google Fonts, shiki syntax
48
53
  highlighting, a Monaco source viewer, and `Source: file:line` links.
49
54
 
@@ -1,4 +1,4 @@
1
- import { ThemeColors, CopyPageConfig, PageNavConfig, SiteLogo, OutputFile } from '@clean-jsdoc-theme/dwar';
1
+ import { OutputFile, ThemeColors, CopyPageConfig, MetaTag, PageNavConfig, SiteLogo } from '@clean-jsdoc-theme/dwar';
2
2
  import { DocInput, MenuItem } from '@clean-jsdoc-theme/setu';
3
3
 
4
4
  interface JSDocOpts {
@@ -106,6 +106,22 @@ interface JSDocOpts {
106
106
  * Defaults to enabled.
107
107
  */
108
108
  pageNav?: unknown;
109
+ /**
110
+ * Custom site footer (`jsdoc.json` `"opts": { "footer": … }`). Either an
111
+ * inline HTML string (v4 parity) or `{ "file": "./footer.html" }` (read from
112
+ * disk by the bridge). Rendered into rang's footer slot in place of the
113
+ * default footer on every page; style it with `customCss`/`customCssFile`.
114
+ * Omit for the default footer.
115
+ */
116
+ footer?: unknown;
117
+ /**
118
+ * Site-wide custom `<meta>` tags (`jsdoc.json` `"opts": { "meta": [...] }`). An
119
+ * array of attribute maps — each object's key/value pairs become one `<meta>`
120
+ * tag in `<head>` (`{ name, content }`, `{ property, content }`, …). dwar
121
+ * escapes values, drops invalid attribute names, and de-dupes against its own
122
+ * head defaults (an author `name: "description"` replaces the auto one).
123
+ */
124
+ meta?: unknown;
109
125
  /**
110
126
  * Inline custom CSS (`jsdoc.json` `"opts": { "customCss": "…" }`), injected as
111
127
  * a `<style>` after the theme stylesheet so it can override.
@@ -163,6 +179,24 @@ interface JSDocOpts {
163
179
  };
164
180
  [key: string]: unknown;
165
181
  }
182
+ /**
183
+ * Resolve `opts.footer` (inline HTML `string` | `{ file }`) into the single
184
+ * `ThemeConfig.footer` string. The `{ file }` form is read from disk HERE — the
185
+ * bridge is the I/O layer, so dwar's `render()` only ever sees the resolved
186
+ * string. A missing/unreadable file is warned about and dropped (resilient,
187
+ * like the logo/custom-asset paths), and an empty value yields `undefined` so
188
+ * the default footer renders. Exported for testing.
189
+ */
190
+ declare function resolveFooter(raw: unknown): Promise<string | undefined>;
191
+ /**
192
+ * Validate `opts.meta` into a clean `MetaTag[]` (attribute maps), or `undefined`
193
+ * when there's nothing usable. Accepts only an array of objects; within each,
194
+ * keeps string→string pairs (trimming the value, coercing finite numbers to
195
+ * strings for convenience) and drops the rest. An entry with no recognized
196
+ * identifying attribute (`name`/`property`/`http-equiv`/`charset`/`itemprop`) is
197
+ * dropped with a warning — dwar does the final escaping + key validation.
198
+ */
199
+ declare function normalizeMeta(raw: unknown): MetaTag[] | undefined;
166
200
  /**
167
201
  * Resolve JSDoc's `templates.default.outputSourceFiles` flag. The `opts` arg
168
202
  * `publish` receives is `env.opts` — the `opts` block — which does NOT carry the
@@ -276,6 +310,22 @@ declare function resolveDocImages(docs: DocInput[], docsDir: string): Promise<{
276
310
  files: OutputFile[];
277
311
  inlineSvgs: Record<string, string>;
278
312
  }>;
313
+ /** The output of {@link resolveDocImages}: resolved docs + their image assets. */
314
+ interface ResolvedDocs {
315
+ docs: DocInput[];
316
+ files: OutputFile[];
317
+ inlineSvgs: Record<string, string>;
318
+ }
319
+ /**
320
+ * Overlay a locale's resolved docs over the default set (the per-locale docs
321
+ * track). A locale page WINS over the default page with the same `path`; a
322
+ * default page absent from the locale falls back (stays). Image asset files are
323
+ * deduped by served path (same content-hashed name → one copy), and inline SVGs
324
+ * merge locale-over-default. Output docs are re-sorted by `path` so the manifest
325
+ * stays stable regardless of merge order. Pure — the I/O already happened in the
326
+ * two {@link resolveDocImages} calls that produced `base`/`locale`.
327
+ */
328
+ declare function overlayDocs(base: ResolvedDocs, locale: ResolvedDocs): ResolvedDocs;
279
329
  /**
280
330
  * Validate `opts.docGroups` into a clean `string[]`, or `undefined` to fall back
281
331
  * to setu's default doc-group order. Mirrors {@link normalizeSectionOrder}:
@@ -284,4 +334,4 @@ declare function resolveDocImages(docs: DocInput[], docsDir: string): Promise<{
284
334
  declare function normalizeDocGroups(raw: unknown): string[] | undefined;
285
335
  declare function publish(data: unknown, opts: JSDocOpts, tutorials?: unknown): Promise<void>;
286
336
 
287
- export { collectDocs, computeRelPaths, hasMarkdownPlugin, normalizeColors, normalizeCopyPage, normalizeDocGroups, normalizeMenu, normalizePageNav, normalizeSectionOrder, outputSourceFilesEnabled, publish, resolveDocImages, sourceLinkToCommentEnabled };
337
+ export { type ResolvedDocs, collectDocs, computeRelPaths, hasMarkdownPlugin, normalizeColors, normalizeCopyPage, normalizeDocGroups, normalizeMenu, normalizeMeta, normalizePageNav, normalizeSectionOrder, outputSourceFilesEnabled, overlayDocs, publish, resolveDocImages, resolveFooter, sourceLinkToCommentEnabled };
package/dist/publish.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ThemeColors, CopyPageConfig, PageNavConfig, SiteLogo, OutputFile } from '@clean-jsdoc-theme/dwar';
1
+ import { OutputFile, ThemeColors, CopyPageConfig, MetaTag, PageNavConfig, SiteLogo } from '@clean-jsdoc-theme/dwar';
2
2
  import { DocInput, MenuItem } from '@clean-jsdoc-theme/setu';
3
3
 
4
4
  interface JSDocOpts {
@@ -106,6 +106,22 @@ interface JSDocOpts {
106
106
  * Defaults to enabled.
107
107
  */
108
108
  pageNav?: unknown;
109
+ /**
110
+ * Custom site footer (`jsdoc.json` `"opts": { "footer": … }`). Either an
111
+ * inline HTML string (v4 parity) or `{ "file": "./footer.html" }` (read from
112
+ * disk by the bridge). Rendered into rang's footer slot in place of the
113
+ * default footer on every page; style it with `customCss`/`customCssFile`.
114
+ * Omit for the default footer.
115
+ */
116
+ footer?: unknown;
117
+ /**
118
+ * Site-wide custom `<meta>` tags (`jsdoc.json` `"opts": { "meta": [...] }`). An
119
+ * array of attribute maps — each object's key/value pairs become one `<meta>`
120
+ * tag in `<head>` (`{ name, content }`, `{ property, content }`, …). dwar
121
+ * escapes values, drops invalid attribute names, and de-dupes against its own
122
+ * head defaults (an author `name: "description"` replaces the auto one).
123
+ */
124
+ meta?: unknown;
109
125
  /**
110
126
  * Inline custom CSS (`jsdoc.json` `"opts": { "customCss": "…" }`), injected as
111
127
  * a `<style>` after the theme stylesheet so it can override.
@@ -163,6 +179,24 @@ interface JSDocOpts {
163
179
  };
164
180
  [key: string]: unknown;
165
181
  }
182
+ /**
183
+ * Resolve `opts.footer` (inline HTML `string` | `{ file }`) into the single
184
+ * `ThemeConfig.footer` string. The `{ file }` form is read from disk HERE — the
185
+ * bridge is the I/O layer, so dwar's `render()` only ever sees the resolved
186
+ * string. A missing/unreadable file is warned about and dropped (resilient,
187
+ * like the logo/custom-asset paths), and an empty value yields `undefined` so
188
+ * the default footer renders. Exported for testing.
189
+ */
190
+ declare function resolveFooter(raw: unknown): Promise<string | undefined>;
191
+ /**
192
+ * Validate `opts.meta` into a clean `MetaTag[]` (attribute maps), or `undefined`
193
+ * when there's nothing usable. Accepts only an array of objects; within each,
194
+ * keeps string→string pairs (trimming the value, coercing finite numbers to
195
+ * strings for convenience) and drops the rest. An entry with no recognized
196
+ * identifying attribute (`name`/`property`/`http-equiv`/`charset`/`itemprop`) is
197
+ * dropped with a warning — dwar does the final escaping + key validation.
198
+ */
199
+ declare function normalizeMeta(raw: unknown): MetaTag[] | undefined;
166
200
  /**
167
201
  * Resolve JSDoc's `templates.default.outputSourceFiles` flag. The `opts` arg
168
202
  * `publish` receives is `env.opts` — the `opts` block — which does NOT carry the
@@ -276,6 +310,22 @@ declare function resolveDocImages(docs: DocInput[], docsDir: string): Promise<{
276
310
  files: OutputFile[];
277
311
  inlineSvgs: Record<string, string>;
278
312
  }>;
313
+ /** The output of {@link resolveDocImages}: resolved docs + their image assets. */
314
+ interface ResolvedDocs {
315
+ docs: DocInput[];
316
+ files: OutputFile[];
317
+ inlineSvgs: Record<string, string>;
318
+ }
319
+ /**
320
+ * Overlay a locale's resolved docs over the default set (the per-locale docs
321
+ * track). A locale page WINS over the default page with the same `path`; a
322
+ * default page absent from the locale falls back (stays). Image asset files are
323
+ * deduped by served path (same content-hashed name → one copy), and inline SVGs
324
+ * merge locale-over-default. Output docs are re-sorted by `path` so the manifest
325
+ * stays stable regardless of merge order. Pure — the I/O already happened in the
326
+ * two {@link resolveDocImages} calls that produced `base`/`locale`.
327
+ */
328
+ declare function overlayDocs(base: ResolvedDocs, locale: ResolvedDocs): ResolvedDocs;
279
329
  /**
280
330
  * Validate `opts.docGroups` into a clean `string[]`, or `undefined` to fall back
281
331
  * to setu's default doc-group order. Mirrors {@link normalizeSectionOrder}:
@@ -284,4 +334,4 @@ declare function resolveDocImages(docs: DocInput[], docsDir: string): Promise<{
284
334
  declare function normalizeDocGroups(raw: unknown): string[] | undefined;
285
335
  declare function publish(data: unknown, opts: JSDocOpts, tutorials?: unknown): Promise<void>;
286
336
 
287
- export { collectDocs, computeRelPaths, hasMarkdownPlugin, normalizeColors, normalizeCopyPage, normalizeDocGroups, normalizeMenu, normalizePageNav, normalizeSectionOrder, outputSourceFilesEnabled, publish, resolveDocImages, sourceLinkToCommentEnabled };
337
+ export { type ResolvedDocs, collectDocs, computeRelPaths, hasMarkdownPlugin, normalizeColors, normalizeCopyPage, normalizeDocGroups, normalizeMenu, normalizeMeta, normalizePageNav, normalizeSectionOrder, outputSourceFilesEnabled, overlayDocs, publish, resolveDocImages, resolveFooter, sourceLinkToCommentEnabled };
package/dist/publish.js CHANGED
@@ -37,11 +37,14 @@ __export(publish_exports, {
37
37
  normalizeCopyPage: () => normalizeCopyPage,
38
38
  normalizeDocGroups: () => normalizeDocGroups,
39
39
  normalizeMenu: () => normalizeMenu,
40
+ normalizeMeta: () => normalizeMeta,
40
41
  normalizePageNav: () => normalizePageNav,
41
42
  normalizeSectionOrder: () => normalizeSectionOrder,
42
43
  outputSourceFilesEnabled: () => outputSourceFilesEnabled,
44
+ overlayDocs: () => overlayDocs,
43
45
  publish: () => publish,
44
46
  resolveDocImages: () => resolveDocImages,
47
+ resolveFooter: () => resolveFooter,
45
48
  sourceLinkToCommentEnabled: () => sourceLinkToCommentEnabled
46
49
  });
47
50
  module.exports = __toCommonJS(publish_exports);
@@ -137,7 +140,7 @@ async function loadDep(name, requiredExports) {
137
140
  }
138
141
  return mod;
139
142
  }
140
- var loadSetu = () => loadDep("@clean-jsdoc-theme/setu", ["generateSite"]);
143
+ var loadSetu = () => loadDep("@clean-jsdoc-theme/setu", ["generateSite", "stampSite"]);
141
144
  var loadDwar = () => loadDep("@clean-jsdoc-theme/dwar", ["render", "runPagefindAgainstDir"]);
142
145
  var loadUtils = () => loadDep("@clean-jsdoc-theme/utils", [
143
146
  "validateThemeOpts",
@@ -145,7 +148,8 @@ var loadUtils = () => loadDep("@clean-jsdoc-theme/utils", [
145
148
  "formatDiagnostics",
146
149
  "formatBuildReport",
147
150
  "normalizeBasePath",
148
- "withBase"
151
+ "withBase",
152
+ "toExtractManifest"
149
153
  ]);
150
154
  var loadOra = async () => {
151
155
  try {
@@ -207,7 +211,16 @@ var defaultTheme = {
207
211
  },
208
212
  basePath: "/"
209
213
  };
210
- function resolveTheme(opts, siteName, fonts, basePath) {
214
+ function resolveFontSet(fonts, locale) {
215
+ const base = defaultTheme.tokens.fonts;
216
+ const override = locale && fonts.locales?.[locale] || {};
217
+ return {
218
+ heading: override.heading ?? fonts.heading ?? base.heading,
219
+ body: override.body ?? fonts.body ?? base.body,
220
+ mono: override.mono ?? fonts.mono ?? base.mono
221
+ };
222
+ }
223
+ function resolveTheme(opts, siteName, fonts, basePath, locale) {
211
224
  const aiPrompt = typeof opts.aiPrompt === "string" && opts.aiPrompt.trim() ? opts.aiPrompt.trim() : void 0;
212
225
  const copyPage = normalizeCopyPage(opts.copyPage);
213
226
  const pageNav = normalizePageNav(opts.pageNav);
@@ -223,11 +236,7 @@ function resolveTheme(opts, siteName, fonts, basePath) {
223
236
  ...defaultTheme.tokens,
224
237
  colors: { ...defaultTheme.tokens.colors, ...colors ?? {} },
225
238
  darkColors: { ...defaultTheme.tokens.darkColors, ...darkColors ?? {} },
226
- fonts: {
227
- heading: fonts.heading ?? defaultTheme.tokens.fonts.heading,
228
- body: fonts.body ?? defaultTheme.tokens.fonts.body,
229
- mono: fonts.mono ?? defaultTheme.tokens.fonts.mono
230
- },
239
+ fonts: resolveFontSet(fonts, locale),
231
240
  ...siteName ? { siteName } : {}
232
241
  }
233
242
  };
@@ -282,6 +291,53 @@ async function resolveCustomAssets(opts, hrefForServed) {
282
291
  files: [...cssAssets.files, ...jsAssets.files]
283
292
  };
284
293
  }
294
+ async function resolveFooter(raw) {
295
+ if (typeof raw === "string") {
296
+ const trimmed = raw.trim();
297
+ return trimmed.length > 0 ? trimmed : void 0;
298
+ }
299
+ if (raw && typeof raw === "object" && typeof raw.file === "string") {
300
+ const file = raw.file.trim();
301
+ if (!file) return void 0;
302
+ try {
303
+ const html = await (0, import_promises2.readFile)((0, import_node_path2.resolve)(file), "utf8");
304
+ return html.trim().length > 0 ? html : void 0;
305
+ } catch {
306
+ console.warn(
307
+ `clean-jsdoc-theme: could not read footer file ('${file}'); omitting the custom footer.`
308
+ );
309
+ return void 0;
310
+ }
311
+ }
312
+ return void 0;
313
+ }
314
+ var META_IDENTITY_ATTRS = ["name", "property", "http-equiv", "charset", "itemprop"];
315
+ function normalizeMeta(raw) {
316
+ if (!Array.isArray(raw)) return void 0;
317
+ const out = [];
318
+ for (const entry of raw) {
319
+ if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
320
+ const o = entry;
321
+ const tag = {};
322
+ for (const [k, v] of Object.entries(o)) {
323
+ if (typeof v === "string") {
324
+ const t = v.trim();
325
+ if (t.length > 0) tag[k] = t;
326
+ } else if (typeof v === "number" && Number.isFinite(v)) {
327
+ tag[k] = String(v);
328
+ }
329
+ }
330
+ const hasIdentity = META_IDENTITY_ATTRS.some((a) => typeof tag[a] === "string");
331
+ if (!hasIdentity || Object.keys(tag).length === 0) {
332
+ console.warn(
333
+ `clean-jsdoc-theme: skipping a meta entry with no usable name/property/http-equiv/charset attribute (${JSON.stringify(entry)}).`
334
+ );
335
+ continue;
336
+ }
337
+ out.push(tag);
338
+ }
339
+ return out.length > 0 ? out : void 0;
340
+ }
285
341
  function isServableUrl(value) {
286
342
  return /^(https?:)?\/\//i.test(value) || /^data:/i.test(value);
287
343
  }
@@ -385,9 +441,7 @@ function sourceLinkToCommentEnabled(opts) {
385
441
  }
386
442
  function hasMarkdownPlugin(plugins) {
387
443
  if (!Array.isArray(plugins)) return false;
388
- return plugins.some(
389
- (p) => typeof p === "string" && /(^|[\\/])markdown(\.js)?$/i.test(p.trim())
390
- );
444
+ return plugins.some((p) => typeof p === "string" && /(^|[\\/])markdown(\.js)?$/i.test(p.trim()));
391
445
  }
392
446
  function assertMarkdownPlugin() {
393
447
  let conf;
@@ -636,6 +690,17 @@ async function resolveDocImages(docs, docsDir) {
636
690
  }
637
691
  return { docs: out, files, inlineSvgs };
638
692
  }
693
+ function overlayDocs(base, locale) {
694
+ const byPath = new Map(base.docs.map((d) => [d.path, d]));
695
+ for (const d of locale.docs) byPath.set(d.path, d);
696
+ const filesByPath = /* @__PURE__ */ new Map();
697
+ for (const f of [...base.files, ...locale.files]) filesByPath.set(f.path, f);
698
+ return {
699
+ docs: [...byPath.values()].sort((a, b) => a.path.localeCompare(b.path)),
700
+ files: [...filesByPath.values()],
701
+ inlineSvgs: { ...base.inlineSvgs, ...locale.inlineSvgs }
702
+ };
703
+ }
639
704
  function normalizeDocGroups(raw) {
640
705
  return normalizeSectionOrder(raw);
641
706
  }
@@ -675,8 +740,33 @@ function createBuildProgress(ora) {
675
740
  }
676
741
  return { stage };
677
742
  }
743
+ function readBuildSpec() {
744
+ const path = process.env.CLEAN_JSDOC_THEME_BUILD?.trim();
745
+ if (!path) return null;
746
+ const spec = JSON.parse((0, import_node_fs.readFileSync)(path, "utf8"));
747
+ if (typeof spec.version === "number" && spec.version !== 1) {
748
+ throw new Error(
749
+ `clean-jsdoc-theme: build spec version ${spec.version} unsupported (expected 1) \u2014 update clean-jsdoc-theme and aadesh together.`
750
+ );
751
+ }
752
+ if (typeof spec.destination !== "string" || typeof spec.basePath !== "string") {
753
+ throw new Error(`clean-jsdoc-theme: malformed build spec at "${path}".`);
754
+ }
755
+ return {
756
+ locale: typeof spec.locale === "string" ? spec.locale : "",
757
+ defaultLocale: typeof spec.defaultLocale === "string" ? spec.defaultLocale : "en",
758
+ apiMessages: spec.apiMessages ?? {},
759
+ chromeMessages: spec.chromeMessages ?? {},
760
+ destination: spec.destination,
761
+ basePath: spec.basePath,
762
+ siteBasePath: typeof spec.siteBasePath === "string" ? spec.siteBasePath : "/",
763
+ locales: Array.isArray(spec.locales) ? spec.locales : [],
764
+ ...typeof spec.docsDir === "string" && spec.docsDir ? { docsDir: spec.docsDir } : {}
765
+ };
766
+ }
678
767
  async function publish(data, opts, tutorials) {
679
- const destination = opts.destination;
768
+ const buildSpec = readBuildSpec();
769
+ const destination = buildSpec?.destination ?? opts.destination;
680
770
  if (!destination || typeof destination !== "string") {
681
771
  throw new Error(
682
772
  'clean-jsdoc-theme publish: opts.destination is required (set "opts.destination" in your jsdoc.json).'
@@ -691,7 +781,7 @@ async function publish(data, opts, tutorials) {
691
781
  const ora = opts.progress === false ? null : await loadOra();
692
782
  const progress = createBuildProgress(ora);
693
783
  const [
694
- { generateSite },
784
+ { generateSite, stampSite },
695
785
  { render, runPagefindAgainstDir },
696
786
  {
697
787
  validateThemeOpts,
@@ -699,7 +789,8 @@ async function publish(data, opts, tutorials) {
699
789
  formatDiagnostics,
700
790
  formatBuildReport,
701
791
  normalizeBasePath,
702
- withBase
792
+ withBase,
793
+ toExtractManifest
703
794
  }
704
795
  // Loaded sequentially (not Promise.all) so the spinner can step its label
705
796
  // through each module — the evaluation of these large ESM bundles is the
@@ -714,7 +805,7 @@ async function publish(data, opts, tutorials) {
714
805
  const utils = await loadUtils();
715
806
  return [setu, dwar, utils];
716
807
  });
717
- const basePath = normalizeBasePath(opts.basePath);
808
+ const basePath = normalizeBasePath(buildSpec?.basePath ?? opts.basePath);
718
809
  const hrefForServed = (servedPath) => withBase(basePath, "/" + servedPath);
719
810
  const fontResolver = createGoogleFontResolver();
720
811
  const { value, diagnostics } = await progress.stage(
@@ -745,12 +836,23 @@ async function publish(data, opts, tutorials) {
745
836
  "Reading sources & docs",
746
837
  async () => {
747
838
  const [srcs, rawDocs] = await Promise.all([sourcesPromise, docsPromise]);
748
- const resolved = docsDir ? await resolveDocImages(rawDocs, docsDir) : { docs: rawDocs, files: [], inlineSvgs: {} };
839
+ const base = docsDir ? await resolveDocImages(rawDocs, docsDir) : { docs: rawDocs, files: [], inlineSvgs: {} };
840
+ if (!buildSpec?.docsDir) {
841
+ return {
842
+ sources: srcs,
843
+ docs: base.docs,
844
+ docImageFiles: base.files,
845
+ inlineSvgs: base.inlineSvgs
846
+ };
847
+ }
848
+ const localeRaw = await collectDocs(buildSpec.docsDir);
849
+ const locale = await resolveDocImages(localeRaw, buildSpec.docsDir);
850
+ const merged = overlayDocs(base, locale);
749
851
  return {
750
852
  sources: srcs,
751
- docs: resolved.docs,
752
- docImageFiles: resolved.files,
753
- inlineSvgs: resolved.inlineSvgs
853
+ docs: merged.docs,
854
+ docImageFiles: merged.files,
855
+ inlineSvgs: merged.inlineSvgs
754
856
  };
755
857
  }
756
858
  );
@@ -759,7 +861,7 @@ async function publish(data, opts, tutorials) {
759
861
  const sectionOrder = normalizeSectionOrder(opts.sectionOrder);
760
862
  const menu = normalizeMenu(opts.menu);
761
863
  const clubSidebarItems = opts.clubSidebarItems === true;
762
- const manifest = await progress.stage("Generating pages", () => generateSite(data, {
864
+ const siteOptions = {
763
865
  ...pkg ? { pkg } : {},
764
866
  ...readme ? { readme } : {},
765
867
  ...tutorialTree.length > 0 ? { tutorials: tutorialTree } : {},
@@ -771,7 +873,23 @@ async function publish(data, opts, tutorials) {
771
873
  ...sectionOrder ? { sectionOrder } : {},
772
874
  ...menu ? { menu } : {},
773
875
  ...clubSidebarItems ? { clubSidebarItems } : {}
774
- }));
876
+ };
877
+ const manifest = await progress.stage(
878
+ "Generating pages",
879
+ () => buildSpec ? stampSite(data, buildSpec.apiMessages, siteOptions) : generateSite(data, siteOptions)
880
+ );
881
+ const extractPath = process.env.CLEAN_JSDOC_THEME_EXTRACT?.trim();
882
+ if (extractPath) {
883
+ const target = (0, import_node_path2.resolve)(extractPath);
884
+ await progress.stage("Writing extract manifest", async () => {
885
+ await (0, import_promises2.mkdir)((0, import_node_path2.dirname)(target), { recursive: true });
886
+ await (0, import_promises2.writeFile)(target, JSON.stringify(toExtractManifest(manifest), null, 2) + "\n", "utf8");
887
+ });
888
+ console.log(
889
+ `clean-jsdoc-theme: extract mode \u2014 wrote ${manifest.slots?.length ?? 0} slot(s) to ${target}`
890
+ );
891
+ return;
892
+ }
775
893
  const { siteName, files: logoFiles } = await prepareSiteName(value.siteName, hrefForServed);
776
894
  const notGoogle = new Set(
777
895
  diagnostics.list.filter((d) => d.code === "fonts/not-google" && d.path).map((d) => d.path)
@@ -779,23 +897,48 @@ async function publish(data, opts, tutorials) {
779
897
  const fonts = { ...value.fonts };
780
898
  if (notGoogle.has("fonts.heading")) delete fonts.heading;
781
899
  if (notGoogle.has("fonts.body")) delete fonts.body;
900
+ if (fonts.locales) {
901
+ const cleaned = {};
902
+ for (const [loc, set] of Object.entries(fonts.locales)) {
903
+ const s = { ...set };
904
+ if (notGoogle.has(`fonts.${loc}:heading`)) delete s.heading;
905
+ if (notGoogle.has(`fonts.${loc}:body`)) delete s.body;
906
+ cleaned[loc] = s;
907
+ }
908
+ fonts.locales = cleaned;
909
+ }
782
910
  const customAssets = await resolveCustomAssets(opts, hrefForServed);
911
+ const footer = await resolveFooter(opts.footer);
912
+ const meta = normalizeMeta(opts.meta);
783
913
  const absoluteDestination = (0, import_node_path2.resolve)(destination);
784
914
  const islandCacheDir = (0, import_node_path2.resolve)(process.cwd(), "node_modules", ".cache", "clean-jsdoc-theme");
785
915
  const result = await progress.stage(
786
916
  "Rendering site",
787
917
  () => render(manifest, {
788
- theme: { ...resolveTheme(opts, siteName, fonts, basePath), ...customAssets.theme },
918
+ theme: {
919
+ ...resolveTheme(opts, siteName, fonts, basePath, buildSpec?.locale),
920
+ ...customAssets.theme,
921
+ ...footer ? { footer } : {},
922
+ ...meta ? { meta } : {}
923
+ },
789
924
  destination: absoluteDestination,
790
925
  islandCacheDir,
791
- inlineSvgs
926
+ inlineSvgs,
927
+ // Build mode: render chrome in the locale (SSR provider + island seeding)
928
+ // and, with >1 locale, mount the language switcher.
929
+ ...buildSpec ? {
930
+ locale: {
931
+ code: buildSpec.locale,
932
+ defaultLocale: buildSpec.defaultLocale,
933
+ messages: buildSpec.chromeMessages,
934
+ siteBasePath: buildSpec.siteBasePath,
935
+ locales: buildSpec.locales.map((l) => ({ code: l.code, label: l.name ?? l.code }))
936
+ }
937
+ } : {}
792
938
  })
793
939
  );
794
940
  const outputFiles = [...result.files, ...logoFiles, ...customAssets.files, ...docImageFiles];
795
- await progress.stage(
796
- "Writing files",
797
- () => writeOutputFiles(absoluteDestination, outputFiles)
798
- );
941
+ await progress.stage("Writing files", () => writeOutputFiles(absoluteDestination, outputFiles));
799
942
  const zlib = await import("zlib");
800
943
  const gzipSizer = (b) => zlib.gzipSync(b).length;
801
944
  console.log(
@@ -821,9 +964,7 @@ async function publish(data, opts, tutorials) {
821
964
  () => runPagefindAgainstDir(absoluteDestination)
822
965
  );
823
966
  } catch (err) {
824
- console.warn(
825
- `clean-jsdoc-theme: pagefind step skipped (optional) \u2014 ${err.message}`
826
- );
967
+ console.warn(`clean-jsdoc-theme: pagefind step skipped (optional) \u2014 ${err.message}`);
827
968
  }
828
969
  }
829
970
  // Annotate the CommonJS export names for ESM import in node:
@@ -835,11 +976,14 @@ async function publish(data, opts, tutorials) {
835
976
  normalizeCopyPage,
836
977
  normalizeDocGroups,
837
978
  normalizeMenu,
979
+ normalizeMeta,
838
980
  normalizePageNav,
839
981
  normalizeSectionOrder,
840
982
  outputSourceFilesEnabled,
983
+ overlayDocs,
841
984
  publish,
842
985
  resolveDocImages,
986
+ resolveFooter,
843
987
  sourceLinkToCommentEnabled
844
988
  });
845
989
  //# sourceMappingURL=publish.js.map