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
22 changes: 22 additions & 0 deletions components/SideBar.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import SideBar from '@node-core/ui-components/Containers/Sidebar';
import { sidebar } from '#theme/site' with { type: 'json' };

/** @param {string} url */
const redirect = url => (window.location.href = url);

const PrefetchLink = props => <a {...props} rel="prefetch" />;

const pathnameFor = path => path.replace(/\/index$/, '') || '/';

/**
* Sidebar component for MDX documentation with page navigation.
*/
export default ({ metadata }) => (
<SideBar
pathname={pathnameFor(metadata.path)}
groups={sidebar}
onSelect={redirect}
as={PrefetchLink}
title="Navigation"
/>
);
22 changes: 20 additions & 2 deletions doc-kit.config.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { major } from 'semver';
import webpack from './webpack/package.json' with { type: 'json' };

const ROOT = dirname(fileURLToPath(import.meta.url));
const DOCS_DIR = `pages/v${major(webpack.version)}.x`;

/**
* Configuration for @node-core/doc-kit when generating webpack API docs.
*
Expand All @@ -9,19 +17,29 @@ export default {
repository: 'webpack/webpack',

// Input & Output
input: ['./pages/v5.x/**/*.md', './pages/v5.x/*.md'],
input: [`./${DOCS_DIR}/**/*.md`],
output: 'out',

// Base URL,
baseURL: process.env.VERCEL_URL
? `https://${process.env.VERCEL_URL}`
: 'http://localhost:3000',
},
threads: 1,
metadata: {
typeMap: './pages/v5.x/type-map.json',
typeMap: `./${DOCS_DIR}/type-map.json`,
},
'jsx-ast': {
generateIndexPage: false,
generateAllPage: false,
},
web: {
project: 'webpack',
useAbsoluteURLs: true,
remoteConfigUrl: null,
imports: {
'#theme/Sidebar': join(ROOT, 'components/SideBar.jsx'),
'#theme/site': join(ROOT, DOCS_DIR, 'site.json'),
},
},
};
Loading