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
Binary file added assets/favicon.ico
Binary file not shown.
Binary file added assets/og_preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 25 additions & 3 deletions scripts/html/doc-kit.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ const MAJOR_VERSION = VERSION ? `v${major(VERSION)}.x` : undefined;

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

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

/**
* Configuration for @node-core/doc-kit when generating webpack API docs.
*
Expand All @@ -23,9 +27,7 @@ export default {
input: [`${inputDir}/**/*.md`],
ignore: VERSION ? [] : ['./pages/api/**/*.md'],
output: VERSION ? `./out/api/${MAJOR_VERSION}` : './out',
baseURL: process.env.VERCEL_URL
? `https://${process.env.VERCEL_URL}`
: 'http://localhost:3000',
baseURL: BASE_URL,
},
threads: 1,
metadata: {
Expand All @@ -39,6 +41,26 @@ export default {
project: 'webpack',
useAbsoluteURLs: true,
remoteConfigUrl: null,
title: VERSION ? `Webpack ${MAJOR_VERSION} Documentation` : 'Webpack',
head: {
meta: [
{
name: 'description',
content:
'Webpack is the build tool for modern web applications run on NodeJS. Webpack is a module bundler and its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable of transforming, bundling, or packaging just about any resource or asset.',
},
{
property: 'og:image',
content: `${BASE_URL}/assets/og_preview.png`,
},
],
links: [
{
rel: 'icon',
href: '/assets/favicon.ico',
},
],
},
imports: {
'#theme/local/site': join(ROOT, inputDir, 'site.json'),

Expand Down
13 changes: 12 additions & 1 deletion scripts/html/index.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { execFile } from 'node:child_process';
import { readFile } from 'node:fs/promises';
import { readFile, cp } from 'node:fs/promises';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { promisify } from 'node:util';

const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..', '..');

const ASSETS_SOURCE = join(ROOT, 'assets');
const ASSETS_DESTINATION = join(ROOT, 'out/assets');

const execFileAsync = promisify(execFile);

const runDocKit = version =>
Expand Down Expand Up @@ -35,3 +42,7 @@ for (const version of versions) {
await runDocKit(version);
}
await runDocKit();

// copy assets folder to the out directory

await cp(ASSETS_SOURCE, ASSETS_DESTINATION, { recursive: true });