mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-16 02: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,
|
showLastUpdateTime: false,
|
||||||
showLastUpdateAuthor: false,
|
showLastUpdateAuthor: false,
|
||||||
admonitions: {},
|
admonitions: {},
|
||||||
|
excludeNextVersionDocs: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
function getFirstDocLinkOfSidebar(
|
function getFirstDocLinkOfSidebar(
|
||||||
|
@ -175,8 +176,12 @@ export default function pluginContentDocs(
|
||||||
// Prepare metadata container.
|
// Prepare metadata container.
|
||||||
const docsMetadataRaw: DocsMetadataRaw = {};
|
const docsMetadataRaw: DocsMetadataRaw = {};
|
||||||
const docsPromises = [];
|
const docsPromises = [];
|
||||||
|
const includeDefaultDocs = !(
|
||||||
|
options.excludeNextVersionDocs && process.argv[2] === 'build'
|
||||||
|
);
|
||||||
|
|
||||||
// Metadata for default/master docs files.
|
// Metadata for default/master docs files.
|
||||||
|
if (includeDefaultDocs) {
|
||||||
const docsFiles = await globby(include, {
|
const docsFiles = await globby(include, {
|
||||||
cwd: docsDir,
|
cwd: docsDir,
|
||||||
});
|
});
|
||||||
|
@ -194,6 +199,7 @@ export default function pluginContentDocs(
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Metadata for versioned docs.
|
// Metadata for versioned docs.
|
||||||
if (versioning.enabled) {
|
if (versioning.enabled) {
|
||||||
|
@ -222,13 +228,14 @@ export default function pluginContentDocs(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the sidebars and create docs ordering.
|
// Load the sidebars and create docs ordering.
|
||||||
const sidebarPaths = [
|
const sidebarPaths = versionsNames.map(
|
||||||
sidebarPath,
|
(versionName) => `${versionedSidebarsDir}/${versionName}-sidebars.json`,
|
||||||
...versionsNames.map(
|
);
|
||||||
(versionName) =>
|
|
||||||
`${versionedSidebarsDir}/${versionName}-sidebars.json`,
|
if (includeDefaultDocs) {
|
||||||
),
|
sidebarPaths.unshift(sidebarPath);
|
||||||
];
|
}
|
||||||
|
|
||||||
const loadedSidebars: Sidebar = loadSidebars(sidebarPaths);
|
const loadedSidebars: Sidebar = loadSidebars(sidebarPaths);
|
||||||
const order: Order = createOrder(loadedSidebars);
|
const order: Order = createOrder(loadedSidebars);
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ export interface PluginOptions extends MetadataOptions, PathOptions {
|
||||||
remarkPlugins: ([Function, object] | Function)[];
|
remarkPlugins: ([Function, object] | Function)[];
|
||||||
rehypePlugins: string[];
|
rehypePlugins: string[];
|
||||||
admonitions: any;
|
admonitions: any;
|
||||||
|
excludeNextVersionDocs: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SidebarItemDoc = {
|
export type SidebarItemDoc = {
|
||||||
|
|
|
@ -288,6 +288,12 @@ module.exports = {
|
||||||
* Whether to display the last date the doc was updated.
|
* Whether to display the last date the doc was updated.
|
||||||
*/
|
*/
|
||||||
showLastUpdateTime: false,
|
showLastUpdateTime: false,
|
||||||
|
/**
|
||||||
|
* Skip the next release docs when versioning is enabled.
|
||||||
|
* This will not generate HTML files in the production build for documents
|
||||||
|
* in `/docs/next` directory, only versioned docs.
|
||||||
|
*/
|
||||||
|
excludeNextVersionDocs: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue