Files
piik/site/docs/build.mjs
T
AAA d8e86667b1 docs: align test guides with the shared help layout
Reuse the published help navigation and theme while preserving 3.0 workflows. Record matched webpage retry and OBS restart acceptance at their existing evidence owners.
2026-11-21 08:43:46 -05:00

26 lines
1.4 KiB
JavaScript

import { appendFile, cp, mkdir, readFile, rm, writeFile } from 'node:fs/promises';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import { build } from 'vitepress';
import { documentBody, pages } from './pages.mjs';
import { writeWebLicenseNotices } from '../../scripts/package-licenses.mjs';
export async function buildDocumentation() {
const root = fileURLToPath(new URL('../../', import.meta.url));
const source = resolve(root, 'build/docs-source');
await rm(source, { recursive: true, force: true });
for (const page of pages) {
const target = resolve(source, page.path);
await mkdir(dirname(target), { recursive: true });
const markdown = await readFile(resolve(root, page.source), 'utf8');
await writeFile(target, documentBody(markdown, page.source));
}
await cp(resolve(root, 'docs/assets'), resolve(source, 'assets'), { recursive: true });
await build(resolve(root, 'site/docs'));
const notices = resolve(root, 'build/site/docs/third-party-licenses.txt');
// The default theme with local search ships these runtimes; the Vite build tool stays local.
writeWebLicenseNotices(resolve(root, 'site/docs'), notices,
['vue', '@vueuse/core', '@vueuse/integrations', 'focus-trap', 'mark.js', 'minisearch']);
await appendFile(notices, '\nVitePress (MIT)\n\n' + await readFile(resolve(root, 'site/docs/node_modules/vitepress/LICENSE'), 'utf8'));
}