@writedocs/generator 0.12.0 → 0.13.1

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.
@@ -1,54 +1,49 @@
1
- // Generated API pages whose address changed between writedocs versions, as
2
- // redirects from the old address to the new one - so links to a published
3
- // site keep working after an update.
4
- //
5
- // One case so far: an operation with no tag used to be served under
6
- // "<path>/untagged/<operation>/" and is now at "<path>/<operation>/".
7
- // generateApiPages() (src/cli/generate-api-pages.js) works the list out
8
- // from the specs and writes it; astro.config.mjs adds it to the site's
9
- // redirects (the redirect pages), src/cli/write-redirects-file.js to
10
- // `_redirects` (real 301s on hosts that read it), and lib/link-check.js
11
- // counts the old addresses as existing.
12
- //
13
- // Plain JavaScript: read by code that runs under plain Node.
14
- import fs from 'node:fs';
15
- import path from 'node:path';
16
- import { writedocsTempDir } from './writedocs-temp-dir.js';
17
-
18
- const fileFor = (contentDir) => path.join(writedocsTempDir(contentDir), 'openapi', 'moved.json');
19
-
20
- /** `[{ source: "/api/untagged/get-pets", destination: "/api/get-pets/" }]` -
21
- * empty when nothing moved, or generateApiPages() hasn't run. */
22
- export function readMovedApiPages(contentDir) {
23
- try {
24
- const list = JSON.parse(fs.readFileSync(fileFor(contentDir), 'utf-8'));
25
- return Array.isArray(list) ? list.filter((r) => typeof r?.source === 'string' && typeof r?.destination === 'string') : [];
26
- } catch {
27
- return [];
28
- }
29
- }
30
-
31
- export function writeMovedApiPages(contentDir, redirects) {
32
- const file = fileFor(contentDir);
33
- fs.mkdirSync(path.dirname(file), { recursive: true });
34
- fs.writeFileSync(file, JSON.stringify(redirects, null, 2));
35
- }
36
-
37
- /** The redirects for one spec's untagged operations. `moved` is
38
- * `[{ oldSlug, newSlug }]` in the spec's order; `taken` holds every slug a
39
- * page is served at (an operation tagged "untagged" still lives under
40
- * that folder - its address isn't a redirect's to take). The folder's own
41
- * address, which used to lead to its first page, goes to that page's new
42
- * address. */
43
- export function untaggedRedirects(pathPrefix, moved, taken) {
44
- const redirects = [];
45
- const free = (slug) => !taken.has(slug);
46
- for (const { oldSlug, newSlug } of moved) {
47
- if (free(oldSlug)) redirects.push({ source: `/${oldSlug}`, destination: `/${newSlug}/` });
48
- }
49
- const folder = `${pathPrefix}/untagged`;
50
- if (moved.length && free(folder) && ![...taken].some((slug) => slug.startsWith(`${folder}/`))) {
51
- redirects.push({ source: `/${folder}`, destination: `/${moved[0].newSlug}/` });
52
- }
53
- return redirects;
54
- }
1
+ // Generated API pages whose address changed between writedocs versions, as
2
+ // redirects from the old address to the new one - so links to a published
3
+ // site keep working after an update.
4
+ //
5
+ // One case so far: an operation with no tag used to be served under
6
+ // "<path>/untagged/<operation>/" and is now at "<path>/<operation>/".
7
+ // generateApiPages() (src/cli/generate-api-pages.js) works the list out
8
+ // from the specs and writes it; astro.config.mjs adds it to the site's
9
+ // redirects (the redirect pages), src/cli/write-redirects-file.js to
10
+ // `_redirects` (real 301s on hosts that read it), and lib/link-check.js
11
+ // counts the old addresses as existing.
12
+ //
13
+ // Plain JavaScript: read by code that runs under plain Node.
14
+ import fs from 'node:fs';
15
+ import path from 'node:path';
16
+ import { writedocsTempDir } from './writedocs-temp-dir.js';
17
+
18
+ /** Where generateApiPages() writes the list (JSON), when anything moved. */
19
+ export const movedApiPagesFile = (contentDir) => path.join(writedocsTempDir(contentDir), 'openapi', 'moved.json');
20
+
21
+ /** `[{ source: "/api/untagged/get-pets", destination: "/api/get-pets/" }]` -
22
+ * empty when nothing moved, or generateApiPages() hasn't run. */
23
+ export function readMovedApiPages(contentDir) {
24
+ try {
25
+ const list = JSON.parse(fs.readFileSync(movedApiPagesFile(contentDir), 'utf-8'));
26
+ return Array.isArray(list) ? list.filter((r) => typeof r?.source === 'string' && typeof r?.destination === 'string') : [];
27
+ } catch {
28
+ return [];
29
+ }
30
+ }
31
+
32
+ /** The redirects for one spec's untagged operations. `moved` is
33
+ * `[{ oldSlug, newSlug }]` in the spec's order; `taken` holds every slug a
34
+ * page is served at (an operation tagged "untagged" still lives under
35
+ * that folder - its address isn't a redirect's to take). The folder's own
36
+ * address, which used to lead to its first page, goes to that page's new
37
+ * address. */
38
+ export function untaggedRedirects(pathPrefix, moved, taken) {
39
+ const redirects = [];
40
+ const free = (slug) => !taken.has(slug);
41
+ for (const { oldSlug, newSlug } of moved) {
42
+ if (free(oldSlug)) redirects.push({ source: `/${oldSlug}`, destination: `/${newSlug}/` });
43
+ }
44
+ const folder = `${pathPrefix}/untagged`;
45
+ if (moved.length && free(folder) && ![...taken].some((slug) => slug.startsWith(`${folder}/`))) {
46
+ redirects.push({ source: `/${folder}`, destination: `/${moved[0].newSlug}/` });
47
+ }
48
+ return redirects;
49
+ }
@@ -0,0 +1,80 @@
1
+ // `writedocs dev`: what the preview knows about the OpenAPI specs between one
2
+ // regeneration and the next - the files to watch, and a spec that stopped
3
+ // parsing. Kept in a file in the project's temp folder, because three places
4
+ // need it: cli/dev.js writes it after the first generateApiPages(),
5
+ // lib/openapi-reload-integration.js after each regeneration (and reads it when
6
+ // the preview restarts), and every page reads it when it renders.
7
+ //
8
+ // A spec that doesn't parse: generateApiPages() writes nothing, so the API
9
+ // pages stay those of the last version that parsed, and every page throws
10
+ // the error instead of rendering (throwIfOpenApiProblem(), called from
11
+ // src/pages/[...slug].astro) - Astro shows it as it shows a broken page or a
12
+ // broken writedocs.json, until the spec parses again.
13
+ //
14
+ // Only `writedocs dev` reads or writes it: a build never looks.
15
+ //
16
+ // Plain JavaScript: the integration and cli/dev.js run under plain Node.
17
+ import fs from 'node:fs';
18
+ import path from 'node:path';
19
+ import { writedocsTempDir } from './writedocs-temp-dir.js';
20
+
21
+ const stateFile = (contentDir) => path.join(writedocsTempDir(contentDir), 'dev-openapi.json');
22
+
23
+ /** `{ sources: [absolute paths], problem: null | specProblem() }` - empty
24
+ * when nothing was written yet. */
25
+ export function readDevOpenApiState(contentDir) {
26
+ try {
27
+ const state = JSON.parse(fs.readFileSync(stateFile(contentDir), 'utf-8'));
28
+ return { sources: Array.isArray(state.sources) ? state.sources : [], problem: state.problem ?? null };
29
+ } catch {
30
+ return { sources: [], problem: null };
31
+ }
32
+ }
33
+
34
+ export function writeDevOpenApiState(contentDir, { sources, problem }) {
35
+ const file = stateFile(contentDir);
36
+ fs.mkdirSync(path.dirname(file), { recursive: true });
37
+ fs.writeFileSync(file, JSON.stringify({ sources, problem: problem ?? null }, null, 2));
38
+ }
39
+
40
+ /** A generateApiPages() failure, for the terminal and the page: the file it
41
+ * is about (absolute, or null), where in it ("openapi.yaml:12:5", relative
42
+ * to the project), and the message without the parser's "Error parsing
43
+ * <file>:" prefix and code frame. */
44
+ export function specProblem(err, contentDir) {
45
+ const firstLine = String(err?.message ?? err).split('\n')[0];
46
+ let message = firstLine.replace(/^\[writedocs\]\s*/, '');
47
+ let file = typeof err?.source === 'string' && err.source ? path.resolve(err.source) : null;
48
+ let line = null;
49
+ let column = null;
50
+ // swagger-parser: "Error parsing <file>: <reason> (12:5)" and "Error
51
+ // opening file <file>: ENOENT: ..." - the file is err.source.
52
+ const parsing = message.match(/^Error (?:parsing|opening file) .+?: (.*)$/);
53
+ if (parsing) message = parsing[1];
54
+ if (err?.ioErrorCode === 'ENOENT' || /^ENOENT\b/.test(message)) message = "This file doesn't exist - a $ref points to it.";
55
+ const pos = message.match(/\s*\((\d+):(\d+)\)\s*$/);
56
+ if (pos) {
57
+ line = Number(pos[1]);
58
+ column = Number(pos[2]);
59
+ message = message.slice(0, pos.index);
60
+ }
61
+ // Errors about writedocs.json's openapi groups (a missing spec, two
62
+ // groups on one path) name no spec file - they're about writedocs.json.
63
+ if (!file && /writedocs\.json/.test(message)) file = path.join(contentDir, 'writedocs.json');
64
+ const rel = file ? path.relative(contentDir, file).split(path.sep).join('/') : null;
65
+ const where = rel ? `${rel}${line ? `:${line}${column ? `:${column}` : ''}` : ''}` : null;
66
+ return { file, line, column, where, message: message.trim() || 'The OpenAPI spec could not be read.' };
67
+ }
68
+
69
+ /** The error a page throws while a spec doesn't parse - nothing otherwise,
70
+ * and nothing outside `writedocs dev`. */
71
+ export function throwIfOpenApiProblem(contentDir) {
72
+ if (process.env.WRITEDOCS_COMMAND !== 'dev') return;
73
+ const { problem } = readDevOpenApiState(contentDir);
74
+ if (!problem) return;
75
+ const err = new Error(problem.where ? `${problem.where} ${problem.message}` : problem.message);
76
+ err.name = 'OpenAPIError';
77
+ err.hint = "The OpenAPI spec can't be read, so the API pages show the last version that could. Fix the spec and the preview reloads by itself.";
78
+ if (problem.file) err.loc = { file: problem.file, line: problem.line ?? undefined, column: problem.column ?? undefined };
79
+ throw err;
80
+ }
@@ -0,0 +1,193 @@
1
+ // `writedocs dev`: an edit to an OpenAPI spec shows up in the preview.
2
+ // generateApiPages() runs once before the preview starts (cli/dev.js); this
3
+ // watches every file it read - each spec writedocs.json's navigation mounts,
4
+ // each spec a page names (Mintlify's "spec.json GET /x") and each file a $ref
5
+ // points into - and runs it again when one of them changes, or when an edit
6
+ // to writedocs.json changes which spec is mounted where.
7
+ //
8
+ // A regeneration writes in two steps (writeInTwoSteps()), so the navigation
9
+ // never names a page Astro doesn't have yet. The navigation comes from the
10
+ // manifest, read on every request; a page is an entry in Astro's content
11
+ // store, which only changes when the generated-docs/ collection is synced
12
+ // again (refreshContent() - content.config.ts doesn't give that collection
13
+ // a watcher of its own, so nothing syncs it halfway). First the pages added
14
+ // or changed, then a sync; then the manifest, the operation JSON and the
15
+ // removal of what went, and a sync if pages went.
16
+ //
17
+ // What reloads the open tab: when pages were added, changed or removed, once
18
+ // the last sync is done this hands Astro its store's change event
19
+ // (contentStoreChanged(), lib/content-store-reload-integration.js) - Astro
20
+ // re-reads the store, clears its routes and reloads the tab. Left to the
21
+ // file watcher, that event came at the first save of the store, which can
22
+ // be before the sync ends: the tab reloaded halfway, and nothing reloaded it
23
+ // again. When only what pages read as they render changed - the operation
24
+ // JSON, the manifest - there's nothing for Astro to re-read: this sends the
25
+ // reload.
26
+ //
27
+ // A spec that doesn't parse leaves the last pages that worked in place
28
+ // (nothing is written then): the error goes to the terminal, and every page
29
+ // shows it until the spec parses again - see lib/openapi-dev-status.js.
30
+ import path from 'node:path';
31
+ import { planApiPages, writeGeneratedFiles } from '../cli/generate-api-pages.js';
32
+ import { collectOpenApiGroups } from './openapi-spec.js';
33
+ import { readConfigText } from './config-file.js';
34
+ import { writedocsTempDir } from './writedocs-temp-dir.js';
35
+ import { report } from './cli-report.js';
36
+ import { readDevOpenApiState, writeDevOpenApiState, specProblem } from './openapi-dev-status.js';
37
+ import { contentStoreChanged } from './content-store-reload-integration.js';
38
+
39
+ /** Wait this long after the last change before regenerating - an editor's
40
+ * save can arrive as more than one write. */
41
+ export const REGENERATE_DELAY_MS = 200;
42
+
43
+ /** Which spec writedocs.json mounts at which path, as one string - null when
44
+ * the file doesn't parse (the preview reports that itself). */
45
+ export function openApiMounts(configText) {
46
+ try {
47
+ const groups = collectOpenApiGroups(JSON.parse(configText).navigation);
48
+ return JSON.stringify(groups.map((group) => [group.openapi.src, group.openapi.path]));
49
+ } catch {
50
+ return null;
51
+ }
52
+ }
53
+
54
+ function mountedSpecs(contentDir) {
55
+ try {
56
+ return collectOpenApiGroups(JSON.parse(readConfigText(contentDir)).navigation).map((group) => path.resolve(contentDir, group.openapi.src));
57
+ } catch {
58
+ return [];
59
+ }
60
+ }
61
+
62
+ const sameFileKey = (file) => (process.platform === 'win32' ? path.resolve(file).toLowerCase() : path.resolve(file));
63
+
64
+ /** The watching itself, apart from Vite. `changed(file)` is called for every
65
+ * file that changed; when it's a watched spec, or writedocs.json with
66
+ * different mounts, `regenerate()` runs after `delayMs` - one run at a time,
67
+ * and once more if something changed during one. `onDone({ ok, result })`
68
+ * or `onDone({ ok: false, error })` follows each run. `files()` is what to
69
+ * watch: the specs generateApiPages() last read (`sources` at first), and
70
+ * the specs writedocs.json mounts even when they don't parse. */
71
+ export function createSpecWatch({ contentDir, sources = [], regenerate, onDone, delayMs = REGENERATE_DELAY_MS }) {
72
+ const configKey = sameFileKey(path.join(contentDir, 'writedocs.json'));
73
+ let watched = new Map();
74
+ const watch = (files) => {
75
+ watched = new Map([...files, ...mountedSpecs(contentDir)].map((file) => [sameFileKey(file), path.resolve(file)]));
76
+ };
77
+ watch(sources);
78
+ let mounts = openApiMounts(readConfigTextOrEmpty(contentDir));
79
+ let timer = null;
80
+ let running = null;
81
+ let again = false;
82
+
83
+ async function run() {
84
+ timer = null;
85
+ if (running) {
86
+ again = true;
87
+ return;
88
+ }
89
+ running = (async () => {
90
+ try {
91
+ const result = await regenerate();
92
+ watch(result.sources);
93
+ await onDone({ ok: true, result });
94
+ } catch (error) {
95
+ watch([...watched.values(), ...(typeof error?.source === 'string' ? [error.source] : [])]);
96
+ await onDone({ ok: false, error });
97
+ }
98
+ })();
99
+ await running;
100
+ running = null;
101
+ if (again) {
102
+ again = false;
103
+ schedule();
104
+ }
105
+ }
106
+ function schedule() {
107
+ clearTimeout(timer);
108
+ timer = setTimeout(run, delayMs);
109
+ }
110
+ return {
111
+ files: () => [...watched.values()],
112
+ changed(file) {
113
+ const key = sameFileKey(file);
114
+ if (key === configKey) {
115
+ const next = openApiMounts(readConfigTextOrEmpty(contentDir));
116
+ if (next === null || next === mounts) return false;
117
+ mounts = next;
118
+ } else if (!watched.has(key)) {
119
+ return false;
120
+ }
121
+ schedule();
122
+ return true;
123
+ },
124
+ /** Resolves when no run is waiting or under way (for tests). */
125
+ async idle() {
126
+ while (timer || running) await (running ?? new Promise((r) => setTimeout(r, delayMs)));
127
+ },
128
+ close() {
129
+ clearTimeout(timer);
130
+ timer = null;
131
+ },
132
+ };
133
+ }
134
+
135
+ function readConfigTextOrEmpty(contentDir) {
136
+ try {
137
+ return readConfigText(contentDir);
138
+ } catch {
139
+ return '';
140
+ }
141
+ }
142
+
143
+ /** generateApiPages() for a running preview: the same files, written in two
144
+ * steps with `refresh()` - a sync of the generated-docs/ collection - after
145
+ * each step that changed pages (see the top of this file). Returns what
146
+ * generateApiPages() returns. */
147
+ export async function writeInTwoSteps({ contentDir, refresh }) {
148
+ const { summary, files, roots } = await planApiPages({ contentDir });
149
+ const isPage = (file) => file.startsWith(roots[0] + path.sep);
150
+ const pages = files && new Map([...files].filter(([file]) => isPage(file)));
151
+ const first = writeGeneratedFiles([], pages);
152
+ if (first.written.length) await refresh();
153
+ const second = writeGeneratedFiles(roots, files, { keepEmptyFolders: true });
154
+ if (second.removed.some(isPage)) await refresh();
155
+ return { ...summary, written: [...first.written, ...second.written], removed: second.removed };
156
+ }
157
+
158
+ export function openapiReload({ contentDir, packageRoot }) {
159
+ return {
160
+ name: 'writedocs-openapi-reload',
161
+ hooks: {
162
+ 'astro:server:setup': ({ server, refreshContent }) => {
163
+ const generatedDocsDir = path.join(writedocsTempDir(contentDir), 'generated-docs');
164
+ const isPage = (file) => file.startsWith(generatedDocsDir + path.sep);
165
+ const reload = () => server.ws.send({ type: 'full-reload', path: '*' });
166
+ // The loader's name: content.config.ts's generatedDocs collection.
167
+ const refresh = () => refreshContent?.({ loaders: ['glob-loader'] });
168
+ const watch = createSpecWatch({
169
+ contentDir,
170
+ sources: readDevOpenApiState(contentDir).sources,
171
+ regenerate: () => writeInTwoSteps({ contentDir, refresh }),
172
+ onDone: async ({ ok, result, error }) => {
173
+ for (const file of watch.files()) server.watcher.add(file);
174
+ if (!ok) {
175
+ const problem = specProblem(error, contentDir);
176
+ writeDevOpenApiState(contentDir, { sources: watch.files(), problem });
177
+ report('error', problem.message, problem.where);
178
+ reload();
179
+ return;
180
+ }
181
+ writeDevOpenApiState(contentDir, { sources: result.sources, problem: null });
182
+ result.warnings.forEach((message) => report('warn', message));
183
+ if ([...result.written, ...result.removed].some(isPage)) contentStoreChanged(server, packageRoot);
184
+ else reload();
185
+ },
186
+ });
187
+ for (const file of watch.files()) server.watcher.add(file);
188
+ for (const event of ['add', 'change', 'unlink']) server.watcher.on(event, (file) => watch.changed(file));
189
+ server.httpServer?.once('close', () => watch.close());
190
+ },
191
+ },
192
+ };
193
+ }
@@ -23,6 +23,7 @@ import {
23
23
  landingSelectors,
24
24
  } from "../lib/config";
25
25
  import { writedocsTempDir } from "../lib/writedocs-temp-dir.js";
26
+ import { throwIfOpenApiProblem } from "../lib/openapi-dev-status.js";
26
27
  import { parseOpenApiRef } from "../lib/openapi-ref.js";
27
28
  import { languageAlternates } from "../lib/item-pages.js";
28
29
  import { wantsGeneratedCard, ogImagePath } from "../lib/og-image.js";
@@ -374,6 +375,9 @@ const {
374
375
 
375
376
  const contentDir = process.env.WRITEDOCS_CONTENT_DIR || process.cwd();
376
377
  const packageRoot = process.env.WRITEDOCS_PACKAGE_ROOT || process.cwd();
378
+ // `writedocs dev`, with an OpenAPI spec that stopped parsing: the error
379
+ // instead of the page, until it parses again (lib/openapi-dev-status.js).
380
+ throwIfOpenApiProblem(contentDir);
377
381
  const config = loadDocsConfig(contentDir);
378
382
  // Once per build, like the lookup tables further down.
379
383
  const sections = oncePerBuild("slug:sections", () => resolveSections(config.navigation));
@@ -1,28 +1,40 @@
1
- /* Wires Tailwind's utility classes into every writedocs build. Nothing in
2
- writedocs' own components (BaseLayout, NavTree, Sidebar, Card, etc.)
3
- uses Tailwind - they keep their existing scoped <style> blocks built
4
- on the --wd-* CSS variables, since those already support per-site
5
- writedocs.json theming (colors, dark mode) at render time. This import
6
- just makes Tailwind's utilities available for custom/future content,
7
- e.g. hand-authored MDX.
8
-
9
- Deliberately importing theme + utilities only, NOT the full
10
- "tailwindcss" entrypoint - that also pulls in Tailwind's preflight
11
- (a browser-default CSS reset), which sets h1-h6's font-size/
12
- font-weight to `inherit`. MDX content headings here rely on the
13
- browser's own default heading styles (nothing in this codebase sets
14
- them explicitly), so preflight was silently collapsing every
15
- heading down to plain paragraph text. Skipping it keeps utility
16
- classes available with zero effect on existing unstyled elements. */
17
- @import "tailwindcss/theme.css";
18
- @import "tailwindcss/utilities.css";
19
-
20
- /* Tailwind's `dark:` variant follows the site's own theme toggle
21
- ([data-theme="dark"] on <html>, set by BaseLayout.astro), not the OS
22
- setting it defaults to - otherwise Mintlify-style light/dark image
23
- pairs (className="block dark:hidden" / "hidden dark:block") show the
24
- wrong one whenever the reader's toggle and their OS disagree. The
25
- site's content directory is added as a Tailwind source at build time
26
- by astro.config.mjs's contentTailwindSource() plugin, since it lives
27
- outside this package where Tailwind looks by default. */
28
- @custom-variant dark (&:where([data-theme="dark"], [data-theme="dark"] *));
1
+ /* Wires Tailwind's utility classes into every writedocs build. Nothing in
2
+ writedocs' own components (BaseLayout, NavTree, Sidebar, Card, etc.)
3
+ uses Tailwind - they keep their existing scoped <style> blocks built
4
+ on the --wd-* CSS variables, since those already support per-site
5
+ writedocs.json theming (colors, dark mode) at render time. This import
6
+ just makes Tailwind's utilities available for custom/future content,
7
+ e.g. hand-authored MDX.
8
+
9
+ Deliberately importing theme + utilities only, NOT the full
10
+ "tailwindcss" entrypoint - that also pulls in Tailwind's preflight
11
+ (a browser-default CSS reset), which sets h1-h6's font-size/
12
+ font-weight to `inherit`. MDX content headings here rely on the
13
+ browser's own default heading styles (nothing in this codebase sets
14
+ them explicitly), so preflight was silently collapsing every
15
+ heading down to plain paragraph text. Skipping it keeps utility
16
+ classes available with zero effect on existing unstyled elements. */
17
+ @import "tailwindcss/theme.css";
18
+ @import "tailwindcss/utilities.css";
19
+
20
+ /* Where Tailwind looks for class names: it scans this package's folder (the
21
+ Vite root). It skips node_modules folders - except when the folder it
22
+ scans is itself inside one, and an installed writedocs always is
23
+ (.../node_modules/@writedocs/generator). With `npm install -g`, the build
24
+ platform's own install, the dependencies sit in that folder: every build
25
+ read all ~27,000 files of node_modules - ~6 s of CPU and, on a cold disk,
26
+ most of a small site's build - and the stylesheet got ~600 rules for
27
+ words that only appear in those files. This skips them in every install,
28
+ as a checkout of this repo always did. The path is from this file:
29
+ ../../ is the package's folder. */
30
+ @source not "../../node_modules";
31
+
32
+ /* Tailwind's `dark:` variant follows the site's own theme toggle
33
+ ([data-theme="dark"] on <html>, set by BaseLayout.astro), not the OS
34
+ setting it defaults to - otherwise Mintlify-style light/dark image
35
+ pairs (className="block dark:hidden" / "hidden dark:block") show the
36
+ wrong one whenever the reader's toggle and their OS disagree. The
37
+ site's content directory is added as a Tailwind source at build time
38
+ by astro.config.mjs's contentTailwindSource() plugin, since it lives
39
+ outside this package where Tailwind looks by default. */
40
+ @custom-variant dark (&:where([data-theme="dark"], [data-theme="dark"] *));