mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-06 02:08:55 +02:00
feat(content-docs): draft docs excluded from build & sidebars (#6457)
Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com> Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
This commit is contained in:
parent
ee4c984bc7
commit
5fb0a2e274
27 changed files with 396 additions and 58 deletions
|
@ -247,6 +247,31 @@ exports[`loadSidebars sidebars with known sidebar item type 1`] = `
|
|||
}
|
||||
`;
|
||||
|
||||
exports[`loadSidebars sidebars with some draft items 1`] = `
|
||||
{
|
||||
"docs": [
|
||||
{
|
||||
"collapsed": true,
|
||||
"collapsible": true,
|
||||
"items": [
|
||||
{
|
||||
"id": "foo/bar",
|
||||
"type": "doc",
|
||||
},
|
||||
{
|
||||
"href": "https://github.com",
|
||||
"label": "GitHub",
|
||||
"type": "link",
|
||||
},
|
||||
],
|
||||
"label": "Test",
|
||||
"link": undefined,
|
||||
"type": "category",
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`loadSidebars undefined path 1`] = `
|
||||
{
|
||||
"defaultSidebar": [
|
||||
|
|
|
@ -10,6 +10,7 @@ import path from 'path';
|
|||
import {loadSidebars, DisabledSidebars} from '../index';
|
||||
import type {SidebarProcessorParams} from '../types';
|
||||
import {DefaultSidebarItemsGenerator} from '../generator';
|
||||
import type {DocMetadata} from '@docusaurus/plugin-content-docs';
|
||||
|
||||
describe('loadSidebars', () => {
|
||||
const fixtureDir = path.join(__dirname, '__fixtures__', 'sidebars');
|
||||
|
@ -24,6 +25,7 @@ describe('loadSidebars', () => {
|
|||
frontMatter: {},
|
||||
},
|
||||
],
|
||||
drafts: [],
|
||||
version: {
|
||||
contentPath: path.join(fixtureDir, 'docs'),
|
||||
contentPathLocalized: path.join(fixtureDir, 'docs'),
|
||||
|
@ -37,6 +39,16 @@ describe('loadSidebars', () => {
|
|||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('sidebars with some draft items', async () => {
|
||||
const sidebarPath = path.join(fixtureDir, 'sidebars.json');
|
||||
const paramsWithDrafts: SidebarProcessorParams = {
|
||||
...params,
|
||||
drafts: [{id: 'foo/baz'} as DocMetadata, {id: 'hello'} as DocMetadata],
|
||||
};
|
||||
const result = await loadSidebars(sidebarPath, paramsWithDrafts);
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('sidebars with deep level of category', async () => {
|
||||
const sidebarPath = path.join(fixtureDir, 'sidebars-category.js');
|
||||
const result = await loadSidebars(sidebarPath, params);
|
||||
|
|
|
@ -46,6 +46,7 @@ describe('processSidebars', () => {
|
|||
const params: SidebarProcessorParams = {
|
||||
sidebarItemsGenerator: StaticSidebarItemsGenerator,
|
||||
docs: [],
|
||||
drafts: [],
|
||||
version,
|
||||
numberPrefixParser: DefaultNumberPrefixParser,
|
||||
categoryLabelSlugger: createSlugger(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue