mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-12 00:27:21 +02:00
feat(v2): allow skipping build docs for next version (#2877)
* feat(v2): allow skipping build docs for next version * Refactor * Refactor Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com>
This commit is contained in:
parent
8304e8253c
commit
bdffd28b9f
3 changed files with 38 additions and 24 deletions
|
@ -63,6 +63,7 @@ const DEFAULT_OPTIONS: PluginOptions = {
|
|||
showLastUpdateTime: false,
|
||||
showLastUpdateAuthor: false,
|
||||
admonitions: {},
|
||||
excludeNextVersionDocs: false,
|
||||
};
|
||||
|
||||
function getFirstDocLinkOfSidebar(
|
||||
|
@ -175,25 +176,30 @@ export default function pluginContentDocs(
|
|||
// Prepare metadata container.
|
||||
const docsMetadataRaw: DocsMetadataRaw = {};
|
||||
const docsPromises = [];
|
||||
const includeDefaultDocs = !(
|
||||
options.excludeNextVersionDocs && process.argv[2] === 'build'
|
||||
);
|
||||
|
||||
// Metadata for default/master docs files.
|
||||
const docsFiles = await globby(include, {
|
||||
cwd: docsDir,
|
||||
});
|
||||
docsPromises.push(
|
||||
Promise.all(
|
||||
docsFiles.map(async (source) => {
|
||||
const metadata: MetadataRaw = await processMetadata({
|
||||
source,
|
||||
refDir: docsDir,
|
||||
context,
|
||||
options,
|
||||
env,
|
||||
});
|
||||
docsMetadataRaw[metadata.id] = metadata;
|
||||
}),
|
||||
),
|
||||
);
|
||||
if (includeDefaultDocs) {
|
||||
const docsFiles = await globby(include, {
|
||||
cwd: docsDir,
|
||||
});
|
||||
docsPromises.push(
|
||||
Promise.all(
|
||||
docsFiles.map(async (source) => {
|
||||
const metadata: MetadataRaw = await processMetadata({
|
||||
source,
|
||||
refDir: docsDir,
|
||||
context,
|
||||
options,
|
||||
env,
|
||||
});
|
||||
docsMetadataRaw[metadata.id] = metadata;
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Metadata for versioned docs.
|
||||
if (versioning.enabled) {
|
||||
|
@ -222,13 +228,14 @@ export default function pluginContentDocs(
|
|||
}
|
||||
|
||||
// Load the sidebars and create docs ordering.
|
||||
const sidebarPaths = [
|
||||
sidebarPath,
|
||||
...versionsNames.map(
|
||||
(versionName) =>
|
||||
`${versionedSidebarsDir}/${versionName}-sidebars.json`,
|
||||
),
|
||||
];
|
||||
const sidebarPaths = versionsNames.map(
|
||||
(versionName) => `${versionedSidebarsDir}/${versionName}-sidebars.json`,
|
||||
);
|
||||
|
||||
if (includeDefaultDocs) {
|
||||
sidebarPaths.unshift(sidebarPath);
|
||||
}
|
||||
|
||||
const loadedSidebars: Sidebar = loadSidebars(sidebarPaths);
|
||||
const order: Order = createOrder(loadedSidebars);
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ export interface PluginOptions extends MetadataOptions, PathOptions {
|
|||
remarkPlugins: ([Function, object] | Function)[];
|
||||
rehypePlugins: string[];
|
||||
admonitions: any;
|
||||
excludeNextVersionDocs: boolean;
|
||||
}
|
||||
|
||||
export type SidebarItemDoc = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue