mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-15 18:17:35 +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,8 +176,12 @@ 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.
|
||||
if (includeDefaultDocs) {
|
||||
const docsFiles = await globby(include, {
|
||||
cwd: docsDir,
|
||||
});
|
||||
|
@ -194,6 +199,7 @@ export default function pluginContentDocs(
|
|||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 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 = {
|
||||
|
|
|
@ -288,6 +288,12 @@ module.exports = {
|
|||
* Whether to display the last date the doc was updated.
|
||||
*/
|
||||
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