Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions scripts/html/doc-kit.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..', '..');

const VERSION = process.env.VERSION;
const MAJOR_VERSION = VERSION ? `v${major(VERSION)}.x` : undefined;
const URL_PATH = VERSION ? `/api/${MAJOR_VERSION}` : '/';

const inputDir = VERSION ? `./pages/api/${MAJOR_VERSION}` : './pages';

const BASE_URL = process.env.VERCEL_URL
const ORIGIN = process.env.VERCEL_URL
? `https://${process.env.VERCEL_URL}`
: 'http://localhost:3000';

const BASE_URL = `${ORIGIN}${URL_PATH}`;

const INPUT_DIR = `./pages/${URL_PATH}`;
const SITE_MODULE = join(ROOT, 'pages/site.mjs');

/**
* Configuration for @node-core/doc-kit when generating webpack API docs.
*
Expand All @@ -24,14 +28,14 @@ export default {
global: {
repository: 'webpack/webpack',
version: VERSION,
input: [`${inputDir}/**/*.md`],
input: [`${INPUT_DIR}/**/*.md`],
ignore: VERSION ? [] : ['./pages/api/**/*.md'],
output: VERSION ? `./out/api/${MAJOR_VERSION}` : './out',
baseURL: BASE_URL,
},
threads: 1,
metadata: {
typeMap: VERSION ? `${inputDir}/type-map.json` : undefined,
typeMap: VERSION ? `${INPUT_DIR}/type-map.json` : undefined,
},
'jsx-ast': {
generateIndexPage: false,
Expand Down Expand Up @@ -63,9 +67,9 @@ export default {
},
imports: {
'#theme/local/site': VERSION
? join(ROOT, inputDir, 'site.json')
: join(ROOT, 'pages/site.mjs'),
'#theme/site': join(ROOT, 'pages/site.mjs'),
? join(ROOT, INPUT_DIR, 'site.json')
: SITE_MODULE,
'#theme/site': SITE_MODULE,

'#theme/Sidebar': join(ROOT, 'components/SideBar.jsx'),
'#theme/sponsors': join(ROOT, 'generated/sponsors.json'),
Expand Down
2 changes: 2 additions & 0 deletions scripts/html/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const runDocKit = version =>
'generate',
'-t',
'web',
'-t',
'orama-db',
'--config-file',
'./scripts/html/doc-kit.config.mjs',
],
Expand Down