Skip to content
Draft
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.
13 changes: 13 additions & 0 deletions scripts/html/doc-kit.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const MAJOR_VERSION = VERSION ? `v${major(VERSION)}.x` : undefined;

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

const Webpack_Description =
'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. ';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be inlined

/**
* Configuration for @node-core/doc-kit when generating webpack API docs.
*
Expand Down Expand Up @@ -39,6 +42,16 @@ export default {
project: 'webpack',
useAbsoluteURLs: true,
remoteConfigUrl: null,
title: VERSION ? `Webpack ${MAJOR_VERSION} Documentation` : 'Webpack',
head: {
meta: [{ name: 'description', content: Webpack_Description }],
links: [
{
rel: 'icon',
href: '/assets/favicon.ico',
},
],
},
imports: {
'#theme/local/site': join(ROOT, inputDir, 'site.json'),

Expand Down
28 changes: 27 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, writeFile } 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,22 @@ 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 });

// title clean up for non api pages: (|Webpack --> Webpack)

const indexPath = join(ROOT, 'out/index.html');

let htmlContent = await readFile(indexPath, 'utf-8');

htmlContent = htmlContent.replace(
'<title>| Webpack</title>',
'<title>Webpack</title>'
);

htmlContent = htmlContent.replace('content=" | Webpack"', 'content="Webpack"');

await writeFile(indexPath, htmlContent, 'utf-8');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fixing this upstream now

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.