kss-modern 1.4.0 → 1.6.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
@@ -6,7 +6,7 @@ A modern, KSS-compatible styleguide generator. Parses KSS comment blocks from CS
6
6
 
7
7
  - KSS-compatible comment parsing from CSS/SCSS files
8
8
  - Live component previews with modifier variants
9
- - Theme dropdowns — a global one in the header (`themes` option) and per-section ones (`Themes:`) — switch previews between the default and themed views
9
+ - Theme dropdowns — a global one in the header (`previewThemes` option) and per-section ones (`Themes:`) — switch previews between the default and themed views, optionally loading a stylesheet per theme
10
10
  - Pug template support via worker thread pool
11
11
  - Color palette and icon gallery documentation
12
12
  - Figma embed integration with light/dark theme sync
@@ -99,29 +99,69 @@ declare function createLogger(tag?: string): Logger;
99
99
  /** Shared styleguide logger instance. */
100
100
  declare const logger: Logger;
101
101
 
102
- interface StyleguideConfiguration {
102
+ /** The styleguide's accent colour: one value, or one per color scheme. */
103
+ type StyleguideBrandColor = string | {
104
+ light: string;
105
+ dark: string;
106
+ };
107
+ /**
108
+ * One entry of the header's **Theme** dropdown — an alternative theme context the previews can be
109
+ * shown in, not a color scheme (that is the separate System/Light/Dark toggle).
110
+ */
111
+ interface PreviewTheme {
112
+ /**
113
+ * The theme's class or class list — `'theme-midnight'`, `'.theme-midnight.compact'` — added to
114
+ * the `<html>` of every preview iframe while the theme is selected.
115
+ */
116
+ value: string;
117
+ /** The label shown in the dropdown. */
118
+ label: string;
119
+ /**
120
+ * Stylesheets loaded into a preview while this theme is selected, layered on top of
121
+ * `html.assets.css` (they are never replaced). Every preview document carries a `<link>` for
122
+ * each of these from the start — inert until the theme is selected — so switching costs no
123
+ * request and shows no flash.
124
+ *
125
+ * The CSS is keyed on the theme's class list, so a section's `Themes:` entry gets the same
126
+ * stylesheets as soon as it resolves to the same classes (`.theme-midnight` here and in the
127
+ * KSS comment); a section theme that matches no configured entry simply loads no extra CSS.
128
+ */
129
+ css?: string[];
130
+ }
131
+ /** Every styleguide option except the accent colour, which carries the deprecated `theme` alias. */
132
+ interface StyleguideOptions {
103
133
  mode: 'development' | 'production';
104
134
  outDir: string;
105
135
  contentDir: `${string}/`;
106
136
  projectTitle: string;
107
137
  deactivateDarkMode?: boolean;
108
- /**
109
- * Themes offered by the header's global **Theme** dropdown. Each entry is a theme class (or class
110
- * list — `'theme-midnight'`, `'.theme-midnight.compact'`) that is added to the `<html>` of every
111
- * preview iframe while selected, plus the label shown in the dropdown. A section's own `Themes:`
112
- * dropdown overrides the global theme for that section.
113
- */
114
- themes?: {
115
- value: string;
116
- label: string;
117
- }[];
118
138
  launchInEditor?: boolean | {
119
139
  rootDir: string;
120
140
  };
121
- theme: string | {
122
- light: string;
123
- dark: string;
124
- };
141
+ /** The themes offered by the header's **Theme** dropdown. */
142
+ previewThemes?: PreviewTheme[];
143
+ /** @deprecated Renamed to `previewThemes`, to tell it apart from `brandColor`. */
144
+ themes?: PreviewTheme[];
145
+ /**
146
+ * Reload a preview iframe when its theme changes, instead of swapping the theme's classes and
147
+ * stylesheets into the loaded document.
148
+ *
149
+ * Off by default: the in-place swap is instant and keeps the preview's state. Turn it on when a
150
+ * preview's own JavaScript reads styling at startup — components that measure, canvas/chart
151
+ * rendering, web components that snapshot tokens on connect — and so needs to run again against
152
+ * the new theme. A preview is reloaded only when the visitor actually changes a theme, never on
153
+ * the initial page load.
154
+ */
155
+ reloadPreviewsOnThemeChange?: boolean;
156
+ /**
157
+ * Let search engines index the generated styleguide.
158
+ *
159
+ * Off by default: a styleguide is internal documentation, and its output directory is usually
160
+ * served from a host that is reachable without being meant for the public. Every build writes a
161
+ * `robots.txt` into the output root, and every page carries a matching `<meta name="robots">` —
162
+ * `noindex, nofollow` while this is off, `index, follow` once it is on.
163
+ */
164
+ allowSearchEngineIndexing?: boolean;
125
165
  logoSignet?: {
126
166
  href: string;
127
167
  } | {
@@ -145,6 +185,35 @@ interface StyleguideConfiguration {
145
185
  ogImage?: (section: in2Section) => string;
146
186
  };
147
187
  }
188
+ /**
189
+ * The styleguide configuration. The accent colour is required under one of its two names:
190
+ * `brandColor`, or the deprecated `theme`.
191
+ *
192
+ * `theme` never had anything to do with the preview themes; it is the colour behind
193
+ * `<meta name="theme-color">`, the generated favicons and the styleguide UI's highlight — hence
194
+ * the rename, which also ends its collision with `themes` / `previewThemes`.
195
+ */
196
+ type StyleguideConfiguration = (StyleguideOptions & {
197
+ brandColor: StyleguideBrandColor;
198
+ theme?: never;
199
+ }) | (StyleguideOptions & {
200
+ /** @deprecated Renamed to `brandColor` — this is the accent colour, not a preview theme. */
201
+ theme: StyleguideBrandColor;
202
+ brandColor?: never;
203
+ });
204
+ /**
205
+ * A configuration with the deprecated aliases resolved away. Everything past
206
+ * {@link resolveConfiguration} works with this, so no internal code has to know about the old names.
207
+ */
208
+ interface ResolvedStyleguideConfiguration extends StyleguideOptions {
209
+ brandColor: StyleguideBrandColor;
210
+ previewThemes: PreviewTheme[];
211
+ }
212
+ /**
213
+ * Resolve the deprecated `theme` / `themes` aliases into `brandColor` / `previewThemes`, warning
214
+ * once per option. Idempotent, so the public entry points can each call it without re-warning.
215
+ */
216
+ declare function resolveConfiguration(config: StyleguideConfiguration | ResolvedStyleguideConfiguration): ResolvedStyleguideConfiguration;
148
217
  interface StyleguideBuildOutput {
149
218
  errors?: {
150
219
  overwrittenSectionsIds?: string[];
@@ -198,7 +267,7 @@ declare function parseStyleguide(contentDir: StyleguideConfiguration['contentDir
198
267
  * Full build: parse, compile every section, and write all fullpage + preview files. Returns the
199
268
  * reusable context so the watcher can perform targeted incremental rebuilds afterwards.
200
269
  */
201
- declare function buildAll(config: StyleguideConfiguration): Promise<{
270
+ declare function buildAll(input: StyleguideConfiguration | ResolvedStyleguideConfiguration): Promise<{
202
271
  errors: StyleguideBuildOutput['errors'];
203
272
  context: StyleguideContext;
204
273
  }>;
@@ -212,7 +281,7 @@ declare function buildStyleguide(config: StyleguideConfiguration): Promise<Style
212
281
  * (cache-aware), re-resolve <insert-markup>, and rewrite just their fullpage + owning preview files.
213
282
  * `changedSectionIds` are the sections whose pug (or a dependency) changed.
214
283
  */
215
- declare function rebuildSections(config: StyleguideConfiguration, context: StyleguideContext, changedSectionIds: Iterable<string>): Promise<void>;
284
+ declare function rebuildSections(config: ResolvedStyleguideConfiguration, context: StyleguideContext, changedSectionIds: Iterable<string>): Promise<void>;
216
285
  /**
217
286
  * What triggered a {@link watchStyleguide} rebuild:
218
287
  * - `structural` — a CSS/SCSS/Markdown edit that can change section structure; the whole styleguide is rebuilt.
@@ -227,11 +296,11 @@ type StyleguideChange = {
227
296
  };
228
297
  /**
229
298
  * Builds the styleguide and watches for changes
230
- * @param config - The configuration for the styleguide
299
+ * @param input - The configuration for the styleguide
231
300
  * @param onChange - Optional callback invoked after each rebuild, with the change that triggered it
232
301
  * @param onError - Optional callback function to call when an error occurs while building the styleguide
233
302
  */
234
- declare function watchStyleguide(config: StyleguideConfiguration, onChange?: (change: StyleguideChange) => void, onError?: (errorData: StyleguideBuildOutput['errors']) => void): Promise<void>;
303
+ declare function watchStyleguide(input: StyleguideConfiguration | ResolvedStyleguideConfiguration, onChange?: (change: StyleguideChange) => void, onError?: (errorData: StyleguideBuildOutput['errors']) => void): Promise<void>;
235
304
 
236
- export { buildAll, buildStyleguide, createLogger, logger, parseStyleguide, rebuildSections, watchStyleguide };
237
- export type { LogBox, Logger, StyleguideChange, StyleguideConfiguration, StyleguideContext };
305
+ export { buildAll, buildStyleguide, createLogger, logger, parseStyleguide, rebuildSections, resolveConfiguration, watchStyleguide };
306
+ export type { LogBox, Logger, PreviewTheme, ResolvedStyleguideConfiguration, StyleguideBrandColor, StyleguideChange, StyleguideConfiguration, StyleguideContext };
@@ -99,29 +99,69 @@ declare function createLogger(tag?: string): Logger;
99
99
  /** Shared styleguide logger instance. */
100
100
  declare const logger: Logger;
101
101
 
102
- interface StyleguideConfiguration {
102
+ /** The styleguide's accent colour: one value, or one per color scheme. */
103
+ type StyleguideBrandColor = string | {
104
+ light: string;
105
+ dark: string;
106
+ };
107
+ /**
108
+ * One entry of the header's **Theme** dropdown — an alternative theme context the previews can be
109
+ * shown in, not a color scheme (that is the separate System/Light/Dark toggle).
110
+ */
111
+ interface PreviewTheme {
112
+ /**
113
+ * The theme's class or class list — `'theme-midnight'`, `'.theme-midnight.compact'` — added to
114
+ * the `<html>` of every preview iframe while the theme is selected.
115
+ */
116
+ value: string;
117
+ /** The label shown in the dropdown. */
118
+ label: string;
119
+ /**
120
+ * Stylesheets loaded into a preview while this theme is selected, layered on top of
121
+ * `html.assets.css` (they are never replaced). Every preview document carries a `<link>` for
122
+ * each of these from the start — inert until the theme is selected — so switching costs no
123
+ * request and shows no flash.
124
+ *
125
+ * The CSS is keyed on the theme's class list, so a section's `Themes:` entry gets the same
126
+ * stylesheets as soon as it resolves to the same classes (`.theme-midnight` here and in the
127
+ * KSS comment); a section theme that matches no configured entry simply loads no extra CSS.
128
+ */
129
+ css?: string[];
130
+ }
131
+ /** Every styleguide option except the accent colour, which carries the deprecated `theme` alias. */
132
+ interface StyleguideOptions {
103
133
  mode: 'development' | 'production';
104
134
  outDir: string;
105
135
  contentDir: `${string}/`;
106
136
  projectTitle: string;
107
137
  deactivateDarkMode?: boolean;
108
- /**
109
- * Themes offered by the header's global **Theme** dropdown. Each entry is a theme class (or class
110
- * list — `'theme-midnight'`, `'.theme-midnight.compact'`) that is added to the `<html>` of every
111
- * preview iframe while selected, plus the label shown in the dropdown. A section's own `Themes:`
112
- * dropdown overrides the global theme for that section.
113
- */
114
- themes?: {
115
- value: string;
116
- label: string;
117
- }[];
118
138
  launchInEditor?: boolean | {
119
139
  rootDir: string;
120
140
  };
121
- theme: string | {
122
- light: string;
123
- dark: string;
124
- };
141
+ /** The themes offered by the header's **Theme** dropdown. */
142
+ previewThemes?: PreviewTheme[];
143
+ /** @deprecated Renamed to `previewThemes`, to tell it apart from `brandColor`. */
144
+ themes?: PreviewTheme[];
145
+ /**
146
+ * Reload a preview iframe when its theme changes, instead of swapping the theme's classes and
147
+ * stylesheets into the loaded document.
148
+ *
149
+ * Off by default: the in-place swap is instant and keeps the preview's state. Turn it on when a
150
+ * preview's own JavaScript reads styling at startup — components that measure, canvas/chart
151
+ * rendering, web components that snapshot tokens on connect — and so needs to run again against
152
+ * the new theme. A preview is reloaded only when the visitor actually changes a theme, never on
153
+ * the initial page load.
154
+ */
155
+ reloadPreviewsOnThemeChange?: boolean;
156
+ /**
157
+ * Let search engines index the generated styleguide.
158
+ *
159
+ * Off by default: a styleguide is internal documentation, and its output directory is usually
160
+ * served from a host that is reachable without being meant for the public. Every build writes a
161
+ * `robots.txt` into the output root, and every page carries a matching `<meta name="robots">` —
162
+ * `noindex, nofollow` while this is off, `index, follow` once it is on.
163
+ */
164
+ allowSearchEngineIndexing?: boolean;
125
165
  logoSignet?: {
126
166
  href: string;
127
167
  } | {
@@ -145,6 +185,35 @@ interface StyleguideConfiguration {
145
185
  ogImage?: (section: in2Section) => string;
146
186
  };
147
187
  }
188
+ /**
189
+ * The styleguide configuration. The accent colour is required under one of its two names:
190
+ * `brandColor`, or the deprecated `theme`.
191
+ *
192
+ * `theme` never had anything to do with the preview themes; it is the colour behind
193
+ * `<meta name="theme-color">`, the generated favicons and the styleguide UI's highlight — hence
194
+ * the rename, which also ends its collision with `themes` / `previewThemes`.
195
+ */
196
+ type StyleguideConfiguration = (StyleguideOptions & {
197
+ brandColor: StyleguideBrandColor;
198
+ theme?: never;
199
+ }) | (StyleguideOptions & {
200
+ /** @deprecated Renamed to `brandColor` — this is the accent colour, not a preview theme. */
201
+ theme: StyleguideBrandColor;
202
+ brandColor?: never;
203
+ });
204
+ /**
205
+ * A configuration with the deprecated aliases resolved away. Everything past
206
+ * {@link resolveConfiguration} works with this, so no internal code has to know about the old names.
207
+ */
208
+ interface ResolvedStyleguideConfiguration extends StyleguideOptions {
209
+ brandColor: StyleguideBrandColor;
210
+ previewThemes: PreviewTheme[];
211
+ }
212
+ /**
213
+ * Resolve the deprecated `theme` / `themes` aliases into `brandColor` / `previewThemes`, warning
214
+ * once per option. Idempotent, so the public entry points can each call it without re-warning.
215
+ */
216
+ declare function resolveConfiguration(config: StyleguideConfiguration | ResolvedStyleguideConfiguration): ResolvedStyleguideConfiguration;
148
217
  interface StyleguideBuildOutput {
149
218
  errors?: {
150
219
  overwrittenSectionsIds?: string[];
@@ -198,7 +267,7 @@ declare function parseStyleguide(contentDir: StyleguideConfiguration['contentDir
198
267
  * Full build: parse, compile every section, and write all fullpage + preview files. Returns the
199
268
  * reusable context so the watcher can perform targeted incremental rebuilds afterwards.
200
269
  */
201
- declare function buildAll(config: StyleguideConfiguration): Promise<{
270
+ declare function buildAll(input: StyleguideConfiguration | ResolvedStyleguideConfiguration): Promise<{
202
271
  errors: StyleguideBuildOutput['errors'];
203
272
  context: StyleguideContext;
204
273
  }>;
@@ -212,7 +281,7 @@ declare function buildStyleguide(config: StyleguideConfiguration): Promise<Style
212
281
  * (cache-aware), re-resolve <insert-markup>, and rewrite just their fullpage + owning preview files.
213
282
  * `changedSectionIds` are the sections whose pug (or a dependency) changed.
214
283
  */
215
- declare function rebuildSections(config: StyleguideConfiguration, context: StyleguideContext, changedSectionIds: Iterable<string>): Promise<void>;
284
+ declare function rebuildSections(config: ResolvedStyleguideConfiguration, context: StyleguideContext, changedSectionIds: Iterable<string>): Promise<void>;
216
285
  /**
217
286
  * What triggered a {@link watchStyleguide} rebuild:
218
287
  * - `structural` — a CSS/SCSS/Markdown edit that can change section structure; the whole styleguide is rebuilt.
@@ -227,11 +296,11 @@ type StyleguideChange = {
227
296
  };
228
297
  /**
229
298
  * Builds the styleguide and watches for changes
230
- * @param config - The configuration for the styleguide
299
+ * @param input - The configuration for the styleguide
231
300
  * @param onChange - Optional callback invoked after each rebuild, with the change that triggered it
232
301
  * @param onError - Optional callback function to call when an error occurs while building the styleguide
233
302
  */
234
- declare function watchStyleguide(config: StyleguideConfiguration, onChange?: (change: StyleguideChange) => void, onError?: (errorData: StyleguideBuildOutput['errors']) => void): Promise<void>;
303
+ declare function watchStyleguide(input: StyleguideConfiguration | ResolvedStyleguideConfiguration, onChange?: (change: StyleguideChange) => void, onError?: (errorData: StyleguideBuildOutput['errors']) => void): Promise<void>;
235
304
 
236
- export { buildAll, buildStyleguide, createLogger, logger, parseStyleguide, rebuildSections, watchStyleguide };
237
- export type { LogBox, Logger, StyleguideChange, StyleguideConfiguration, StyleguideContext };
305
+ export { buildAll, buildStyleguide, createLogger, logger, parseStyleguide, rebuildSections, resolveConfiguration, watchStyleguide };
306
+ export type { LogBox, Logger, PreviewTheme, ResolvedStyleguideConfiguration, StyleguideBrandColor, StyleguideChange, StyleguideConfiguration, StyleguideContext };
@@ -1344,6 +1344,18 @@ async function logicalWriteFile(filepath, content) {
1344
1344
  await fs.writeFile(filepath, content);
1345
1345
  }
1346
1346
 
1347
+ const ROBOTS_FILE_NAME = "robots.txt";
1348
+ function generateRobotsTxt(allowSearchEngineIndexing) {
1349
+ const rule = allowSearchEngineIndexing ? "Allow: /" : "Disallow: /";
1350
+ return `# Generated by kss-modern
1351
+ User-agent: *
1352
+ ${rule}
1353
+ `;
1354
+ }
1355
+ async function writeRobotsFile(outDir, allowSearchEngineIndexing) {
1356
+ await logicalWriteFile(path.join(outDir, ROBOTS_FILE_NAME), generateRobotsTxt(allowSearchEngineIndexing));
1357
+ }
1358
+
1347
1359
  async function generateFullPageFile(data) {
1348
1360
  const supportsDarkMode = !(data.deactivateDarkMode ?? false);
1349
1361
  const computedScriptTags = data.js.filter((entry) => entry.type !== "overwriteStyleguide").map((js) => {
@@ -1353,6 +1365,7 @@ async function generateFullPageFile(data) {
1353
1365
  const computedStyleTags = data.css.filter((entry) => entry.type !== "overwriteStyleguide").map((css) => {
1354
1366
  return `<link rel="stylesheet" type="text/css" href="${css.src}">`;
1355
1367
  }).join("\n");
1368
+ const computedThemeStyleTags = (data.previewThemes ?? []).flatMap((theme) => (theme.css ?? []).map((src) => ({ src, classList: themeClassList(theme.value) }))).filter((entry) => entry.classList).map((entry) => `<link rel="stylesheet" type="text/css" href="${entry.src}" media="not all" data-theme-css="${sanitizeSpecialCharacters(entry.classList)}">`).join("\n");
1356
1369
  const content = `
1357
1370
  <!DOCTYPE html>
1358
1371
  <html lang="${data.page.lang}"${data.page.htmlclass ? ` class="scroll-smooth ${data.page.htmlclass}"` : ""} data-styleguide-dark-mode="${supportsDarkMode}">
@@ -1362,14 +1375,16 @@ async function generateFullPageFile(data) {
1362
1375
  <meta charset="UTF-8">
1363
1376
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
1364
1377
  <meta name="generator" content="styleguide">
1378
+ <meta name="robots" content="${data.allowSearchEngineIndexing ? "index, follow" : "noindex, nofollow"}">
1365
1379
  <link rel="icon" type="image/svg+xml" href="/styleguide-assets/favicon/fullpage.svg">
1366
1380
  ${data.ogImageUrl ? `<meta property="og:image" content="${data.ogImageUrl}">` : ""}
1367
- ${typeof data.theme === "object" && "dark" in data.theme && "light" in data.theme ? `
1368
- <meta name="theme-color" media="(prefers-color-scheme: light)" content="${data.theme.light}">
1369
- <meta name="theme-color" media="(prefers-color-scheme: dark)" content="${data.theme.dark}">
1370
- ` : `<meta name="theme-color" content="${data.theme}">`}
1371
- <script type="module" src="/styleguide-assets/fullpage-B7IV3eSt.js"><\/script>
1381
+ ${typeof data.brandColor === "object" && "dark" in data.brandColor && "light" in data.brandColor ? `
1382
+ <meta name="theme-color" media="(prefers-color-scheme: light)" content="${data.brandColor.light}">
1383
+ <meta name="theme-color" media="(prefers-color-scheme: dark)" content="${data.brandColor.dark}">
1384
+ ` : `<meta name="theme-color" content="${data.brandColor}">`}
1385
+ <script type="module" src="/styleguide-assets/fullpage-DSD6-0qF.js"><\/script>
1372
1386
  ${computedStyleTags}
1387
+ ${computedThemeStyleTags}
1373
1388
  </head>
1374
1389
  <body${data.page.bodyclass ? ` class="${data.page.bodyclass}"` : ""}>
1375
1390
  ${data.html}
@@ -1435,7 +1450,7 @@ function getHeaderHtml(config) {
1435
1450
  </button>
1436
1451
 
1437
1452
  <div class="flex gap-4">
1438
- ${config.themes?.length ? renderGlobalThemeSelect(config.themes) : ""}
1453
+ ${config.previewThemes.length > 0 ? renderGlobalThemeSelect(config.previewThemes) : ""}
1439
1454
  ${config.mode === "development" && config.launchInEditor ? `
1440
1455
  <form class="hidden editor-select md:block">
1441
1456
  <fieldset class="flex items-center rounded-3xl border border-styleguide-border">
@@ -2219,19 +2234,20 @@ async function generatePreviewFile(data) {
2219
2234
  const shouldRenderMetaDescription = data.page.description && data.page.description.length > 0 && !(data.page.description.includes("<") && data.page.description.includes(">"));
2220
2235
  const content = `
2221
2236
  <!DOCTYPE html>
2222
- <html lang="${data.page.lang}" class="scroll-smooth">
2237
+ <html lang="${data.page.lang}" class="scroll-smooth"${data.reloadPreviewsOnThemeChange ? " data-reload-previews-on-theme-change" : ""}>
2223
2238
  <head>
2224
2239
  <title>${sanitizeSpecialCharacters(data.page.title)}</title>
2225
2240
  ${data.page.description && shouldRenderMetaDescription ? `<meta name="description" content="${data.page.description.replaceAll(`'`, "").replaceAll(`"`, "")}">` : ""}
2226
2241
  <meta charset="UTF-8">
2227
2242
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
2228
2243
  <meta name="generator" content="styleguide">
2244
+ <meta name="robots" content="${data.allowSearchEngineIndexing ? "index, follow" : "noindex, nofollow"}">
2229
2245
  <link rel="icon" type="image/svg+xml" href="/styleguide-assets/favicon/preview.svg">
2230
2246
  ${data.ogImageUrl ? `<meta property="og:image" content="${data.ogImageUrl}">` : ""}
2231
- ${typeof data.theme === "object" && "dark" in data.theme && "light" in data.theme ? `
2232
- <meta name="theme-color" media="(prefers-color-scheme: light)" content="${data.theme.light}">
2233
- <meta name="theme-color" media="(prefers-color-scheme: dark)" content="${data.theme.dark}">
2234
- ` : `<meta name="theme-color" content="${data.theme}">`}
2247
+ ${typeof data.brandColor === "object" && "dark" in data.brandColor && "light" in data.brandColor ? `
2248
+ <meta name="theme-color" media="(prefers-color-scheme: light)" content="${data.brandColor.light}">
2249
+ <meta name="theme-color" media="(prefers-color-scheme: dark)" content="${data.brandColor.dark}">
2250
+ ` : `<meta name="theme-color" content="${data.brandColor}">`}
2235
2251
  <link rel="stylesheet" type="text/css" href="/styleguide-assets/kss-modern-Cg1aeKi1.css">
2236
2252
  <script>
2237
2253
  //#region client/lib/iframe-resize.ts
@@ -2395,7 +2411,7 @@ document.addEventListener("DOMContentLoaded", () => {
2395
2411
  //#endregion
2396
2412
  ;
2397
2413
  <\/script>
2398
- <script type="module" src="/styleguide-assets/preview-tkLDBWOv.js"><\/script>
2414
+ <script type="module" src="/styleguide-assets/preview-CCjPdowU.js"><\/script>
2399
2415
  <link rel="preload" href="/styleguide-assets/fonts/geist-mono-latin-400-normal.woff2" as="font" type="font/woff2" crossorigin="anonymous">
2400
2416
  <link rel="preload" href="/styleguide-assets/fonts/geist-mono-latin-600-normal.woff2" as="font" type="font/woff2" crossorigin="anonymous">
2401
2417
  <link rel="preload" href="/styleguide-assets/fonts/geist-mono-latin-300-normal.woff2" as="font" type="font/woff2" crossorigin="anonymous">
@@ -2405,7 +2421,7 @@ document.addEventListener("DOMContentLoaded", () => {
2405
2421
  ${computedStyleTags}
2406
2422
  <style>
2407
2423
  :root {
2408
- --styleguide-color-theme-highlight: ${typeof data.theme === "string" ? data.theme : `light-dark(${data.theme.light}, ${data.theme.dark})`};
2424
+ --styleguide-color-theme-highlight: ${typeof data.brandColor === "string" ? data.brandColor : `light-dark(${data.brandColor.light}, ${data.brandColor.dark})`};
2409
2425
  }
2410
2426
  </style>
2411
2427
  </head>
@@ -2595,6 +2611,28 @@ function watchStyleguideForChanges(watchPath, handlers) {
2595
2611
  });
2596
2612
  }
2597
2613
 
2614
+ const warnedDeprecations = /* @__PURE__ */ new Set();
2615
+ function warnDeprecatedOption(deprecated, replacement) {
2616
+ if (warnedDeprecations.has(deprecated))
2617
+ return;
2618
+ warnedDeprecations.add(deprecated);
2619
+ logger.warn(`\`${deprecated}\` is deprecated and will be removed in the next major \u2014 rename it to \`${replacement}\`.`);
2620
+ }
2621
+ function resolveConfiguration(config) {
2622
+ const { theme, themes, ...options } = config;
2623
+ if (theme !== void 0)
2624
+ warnDeprecatedOption("theme", "brandColor");
2625
+ if (themes !== void 0)
2626
+ warnDeprecatedOption("themes", "previewThemes");
2627
+ const brandColor = options.brandColor ?? theme;
2628
+ if (brandColor === void 0)
2629
+ throw new Error("Styleguide configuration is missing `brandColor` (the styleguide accent colour).");
2630
+ return {
2631
+ ...options,
2632
+ brandColor,
2633
+ previewThemes: options.previewThemes ?? themes ?? []
2634
+ };
2635
+ }
2598
2636
  async function parseStyleguide(contentDir) {
2599
2637
  const styleguideContentPaths = await glob(`${contentDir}/**/*.{css,scss}`);
2600
2638
  const styleguideContent = await Promise.all(
@@ -2665,9 +2703,11 @@ async function writeFullPageFile(config, baseDirectory, section) {
2665
2703
  },
2666
2704
  css: config.html.assets.css,
2667
2705
  js: config.html.assets.js,
2706
+ previewThemes: config.previewThemes,
2668
2707
  html: htmlMarkup,
2669
- theme: config.theme,
2708
+ brandColor: config.brandColor,
2670
2709
  deactivateDarkMode: config.deactivateDarkMode,
2710
+ allowSearchEngineIndexing: config.allowSearchEngineIndexing,
2671
2711
  ogImageUrl: config.plugins?.ogImage ? config.plugins.ogImage(section) : void 0
2672
2712
  });
2673
2713
  } catch (error) {
@@ -2723,8 +2763,10 @@ function writePreviewFile(config, context, firstLevelIndex, secondLevelIndex) {
2723
2763
  alerts: getAlerts(),
2724
2764
  preloadIframes
2725
2765
  },
2726
- theme: config.theme,
2766
+ brandColor: config.brandColor,
2727
2767
  deactivateDarkMode: config.deactivateDarkMode,
2768
+ allowSearchEngineIndexing: config.allowSearchEngineIndexing,
2769
+ reloadPreviewsOnThemeChange: config.reloadPreviewsOnThemeChange,
2728
2770
  ogImageUrl: config.plugins?.ogImage ? config.plugins.ogImage(secondLevelSection) : void 0
2729
2771
  });
2730
2772
  }
@@ -2805,9 +2847,9 @@ async function buildContext(config) {
2805
2847
  };
2806
2848
  }
2807
2849
  const ASSETS_MARKER_FILE = ".kss-modern-assets";
2808
- function getAssetsBuildId(theme) {
2850
+ function getAssetsBuildId(brandColor) {
2809
2851
  return `kss-modern-Cg1aeKi1.css
2810
- ${JSON.stringify(theme)}
2852
+ ${JSON.stringify(brandColor)}
2811
2853
  `;
2812
2854
  }
2813
2855
  async function readAssetsBuildId(markerPath) {
@@ -2829,17 +2871,18 @@ async function copyStyleguideAssets(config) {
2829
2871
  const assetsDirectoryPath = findAssetsDirectoryPath();
2830
2872
  const assetsDirectoryOutputPath = path.join(config.outDir, "styleguide-assets");
2831
2873
  const markerPath = path.join(assetsDirectoryOutputPath, ASSETS_MARKER_FILE);
2832
- const expectedBuildId = getAssetsBuildId(config.theme);
2874
+ const expectedBuildId = getAssetsBuildId(config.brandColor);
2833
2875
  const currentBuildId = await readAssetsBuildId(markerPath);
2834
2876
  if (currentBuildId === expectedBuildId) {
2835
2877
  return;
2836
2878
  }
2837
2879
  await fs.remove(assetsDirectoryOutputPath);
2838
2880
  await fs.copy(assetsDirectoryPath, assetsDirectoryOutputPath);
2839
- await generateFaviconFiles(assetsDirectoryOutputPath, config.theme);
2881
+ await generateFaviconFiles(assetsDirectoryOutputPath, config.brandColor);
2840
2882
  await fs.writeFile(markerPath, expectedBuildId);
2841
2883
  }
2842
- async function buildAll(config) {
2884
+ async function buildAll(input) {
2885
+ const config = resolveConfiguration(input);
2843
2886
  if (config.mode === "production" && await fs.exists(config.outDir)) {
2844
2887
  const files = await glob(`${config.outDir}/**/*.html`);
2845
2888
  await Promise.all(files.map((file) => fs.remove(file)));
@@ -2859,7 +2902,11 @@ async function buildAll(config) {
2859
2902
  fileWriteTasks.push(writePreviewFile(config, context, firstLevelIndex, secondLevelIndex));
2860
2903
  });
2861
2904
  });
2862
- await Promise.all([copyStyleguideAssets(config), ...fileWriteTasks]);
2905
+ await Promise.all([
2906
+ copyStyleguideAssets(config),
2907
+ writeRobotsFile(config.outDir, config.allowSearchEngineIndexing ?? false),
2908
+ ...fileWriteTasks
2909
+ ]);
2863
2910
  const errors = {};
2864
2911
  if (context.overwrittenSectionsIds.length > 0) {
2865
2912
  errors.overwrittenSectionsIds = context.overwrittenSectionsIds;
@@ -2926,7 +2973,8 @@ async function rebuildSections(config, context, changedSectionIds) {
2926
2973
  }
2927
2974
  await Promise.all(writeTasks);
2928
2975
  }
2929
- async function watchStyleguide(config, onChange, onError) {
2976
+ async function watchStyleguide(input, onChange, onError) {
2977
+ const config = resolveConfiguration(input);
2930
2978
  const initialBuild = await buildAll(config);
2931
2979
  if (onError && initialBuild.errors) {
2932
2980
  onError(initialBuild.errors);
@@ -2966,4 +3014,4 @@ async function watchStyleguide(config, onChange, onError) {
2966
3014
  });
2967
3015
  }
2968
3016
 
2969
- export { buildAll, buildStyleguide, logger, parseStyleguide, rebuildSections, watchStyleguide };
3017
+ export { buildAll, buildStyleguide, logger, parseStyleguide, rebuildSections, resolveConfiguration, watchStyleguide };
@@ -11,10 +11,11 @@
11
11
  "file": "code-highlight-Fm7cxf-E.js",
12
12
  "name": "code-highlight"
13
13
  },
14
- "_preview-theme-DS4xqXIm.js": {
15
- "file": "preview-theme-DS4xqXIm.js",
14
+ "_preview-theme-DIgnwL5g.js": {
15
+ "file": "preview-theme-DIgnwL5g.js",
16
16
  "name": "preview-theme",
17
17
  "imports": [
18
+ "_theme-document-CtY2qFyJ.js",
18
19
  "_section-previews-CnlrC8Gz.js"
19
20
  ]
20
21
  },
@@ -34,18 +35,23 @@
34
35
  "file": "signal-ZVBNTRLw.js",
35
36
  "name": "signal"
36
37
  },
38
+ "_theme-document-CtY2qFyJ.js": {
39
+ "file": "theme-document-CtY2qFyJ.js",
40
+ "name": "theme-document"
41
+ },
37
42
  "_utils-DtB-AzJa.js": {
38
43
  "file": "utils-DtB-AzJa.js",
39
44
  "name": "utils"
40
45
  },
41
46
  "client/fullpage.ts": {
42
- "file": "fullpage-B7IV3eSt.js",
47
+ "file": "fullpage-DSD6-0qF.js",
43
48
  "name": "fullpage",
44
49
  "src": "client/fullpage.ts",
45
50
  "isEntry": true,
46
51
  "imports": [
47
52
  "_rolldown-runtime-B1bRi_D7.js",
48
- "_shared-hGcWlnRM.js"
53
+ "_shared-hGcWlnRM.js",
54
+ "_theme-document-CtY2qFyJ.js"
49
55
  ],
50
56
  "dynamicImports": [
51
57
  "node_modules/axe-core/axe.js",
@@ -81,12 +87,12 @@
81
87
  "isDynamicEntry": true
82
88
  },
83
89
  "client/lib/global-theme-select.ts": {
84
- "file": "global-theme-select-DM7GN8Dn.js",
90
+ "file": "global-theme-select-DCnqGEUr.js",
85
91
  "name": "global-theme-select",
86
92
  "src": "client/lib/global-theme-select.ts",
87
93
  "isDynamicEntry": true,
88
94
  "imports": [
89
- "_preview-theme-DS4xqXIm.js"
95
+ "_preview-theme-DIgnwL5g.js"
90
96
  ]
91
97
  },
92
98
  "client/lib/html-validator.ts": {
@@ -113,13 +119,13 @@
113
119
  ]
114
120
  },
115
121
  "client/lib/section-theme-select.ts": {
116
- "file": "section-theme-select-BHhiP4pl.js",
122
+ "file": "section-theme-select-CVOwp7VZ.js",
117
123
  "name": "section-theme-select",
118
124
  "src": "client/lib/section-theme-select.ts",
119
125
  "isDynamicEntry": true,
120
126
  "imports": [
121
127
  "_section-previews-CnlrC8Gz.js",
122
- "_preview-theme-DS4xqXIm.js"
128
+ "_preview-theme-DIgnwL5g.js"
123
129
  ]
124
130
  },
125
131
  "client/preview-inline.ts": {
@@ -129,7 +135,7 @@
129
135
  "isEntry": true
130
136
  },
131
137
  "client/preview.ts": {
132
- "file": "preview-tkLDBWOv.js",
138
+ "file": "preview-CCjPdowU.js",
133
139
  "name": "preview",
134
140
  "src": "client/preview.ts",
135
141
  "isEntry": true,