mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-06 10:20:09 +02:00
feat(docs,blog,pages): add support for "unlisted" front matter - hide md content in production (#8004)
Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com>
This commit is contained in:
parent
7a023a2c41
commit
683ba3d2a0
131 changed files with 2449 additions and 303 deletions
|
@ -153,7 +153,14 @@ describe('createSidebarsUtils', () => {
|
|||
});
|
||||
|
||||
it('getDocNavigation', () => {
|
||||
expect(getDocNavigation('doc1', 'doc1', undefined)).toEqual({
|
||||
expect(
|
||||
getDocNavigation({
|
||||
unversionedId: 'doc1',
|
||||
versionedId: 'doc1',
|
||||
displayedSidebar: undefined,
|
||||
unlistedIds: new Set(),
|
||||
}),
|
||||
).toEqual({
|
||||
sidebarName: 'sidebar1',
|
||||
previous: undefined,
|
||||
next: {
|
||||
|
@ -161,7 +168,14 @@ describe('createSidebarsUtils', () => {
|
|||
id: 'doc2',
|
||||
},
|
||||
});
|
||||
expect(getDocNavigation('doc2', 'doc2', undefined)).toEqual({
|
||||
expect(
|
||||
getDocNavigation({
|
||||
unversionedId: 'doc2',
|
||||
versionedId: 'doc2',
|
||||
displayedSidebar: undefined,
|
||||
unlistedIds: new Set(),
|
||||
}),
|
||||
).toEqual({
|
||||
sidebarName: 'sidebar1',
|
||||
previous: {
|
||||
type: 'doc',
|
||||
|
@ -170,7 +184,14 @@ describe('createSidebarsUtils', () => {
|
|||
next: undefined,
|
||||
});
|
||||
|
||||
expect(getDocNavigation('doc3', 'doc3', undefined)).toEqual({
|
||||
expect(
|
||||
getDocNavigation({
|
||||
unversionedId: 'doc3',
|
||||
versionedId: 'doc3',
|
||||
displayedSidebar: undefined,
|
||||
unlistedIds: new Set(),
|
||||
}),
|
||||
).toEqual({
|
||||
sidebarName: 'sidebar2',
|
||||
previous: undefined,
|
||||
next: {
|
||||
|
@ -178,7 +199,14 @@ describe('createSidebarsUtils', () => {
|
|||
id: 'doc4',
|
||||
},
|
||||
});
|
||||
expect(getDocNavigation('doc4', 'doc4', undefined)).toEqual({
|
||||
expect(
|
||||
getDocNavigation({
|
||||
unversionedId: 'doc4',
|
||||
versionedId: 'doc4',
|
||||
displayedSidebar: undefined,
|
||||
unlistedIds: new Set(),
|
||||
}),
|
||||
).toEqual({
|
||||
sidebarName: 'sidebar2',
|
||||
previous: {
|
||||
type: 'doc',
|
||||
|
@ -188,7 +216,14 @@ describe('createSidebarsUtils', () => {
|
|||
next: undefined,
|
||||
});
|
||||
|
||||
expect(getDocNavigation('doc5', 'doc5', undefined)).toMatchObject({
|
||||
expect(
|
||||
getDocNavigation({
|
||||
unversionedId: 'doc5',
|
||||
versionedId: 'doc5',
|
||||
displayedSidebar: undefined,
|
||||
unlistedIds: new Set(),
|
||||
}),
|
||||
).toMatchObject({
|
||||
sidebarName: 'sidebar3',
|
||||
previous: undefined,
|
||||
next: {
|
||||
|
@ -196,7 +231,14 @@ describe('createSidebarsUtils', () => {
|
|||
label: 'S3 SubCategory',
|
||||
},
|
||||
});
|
||||
expect(getDocNavigation('doc6', 'doc6', undefined)).toMatchObject({
|
||||
expect(
|
||||
getDocNavigation({
|
||||
unversionedId: 'doc6',
|
||||
versionedId: 'doc6',
|
||||
displayedSidebar: undefined,
|
||||
unlistedIds: new Set(),
|
||||
}),
|
||||
).toMatchObject({
|
||||
sidebarName: 'sidebar3',
|
||||
previous: {
|
||||
type: 'category',
|
||||
|
@ -207,7 +249,14 @@ describe('createSidebarsUtils', () => {
|
|||
id: 'doc7',
|
||||
},
|
||||
});
|
||||
expect(getDocNavigation('doc7', 'doc7', undefined)).toEqual({
|
||||
expect(
|
||||
getDocNavigation({
|
||||
unversionedId: 'doc7',
|
||||
versionedId: 'doc7',
|
||||
displayedSidebar: undefined,
|
||||
unlistedIds: new Set(),
|
||||
}),
|
||||
).toEqual({
|
||||
sidebarName: 'sidebar3',
|
||||
previous: {
|
||||
type: 'doc',
|
||||
|
@ -215,17 +264,36 @@ describe('createSidebarsUtils', () => {
|
|||
},
|
||||
next: undefined,
|
||||
});
|
||||
expect(getDocNavigation('doc3', 'doc3', null)).toEqual({
|
||||
expect(
|
||||
getDocNavigation({
|
||||
unversionedId: 'doc3',
|
||||
versionedId: 'doc3',
|
||||
displayedSidebar: null,
|
||||
unlistedIds: new Set(),
|
||||
}),
|
||||
).toEqual({
|
||||
sidebarName: undefined,
|
||||
previous: undefined,
|
||||
next: undefined,
|
||||
});
|
||||
expect(() =>
|
||||
getDocNavigation('doc3', 'doc3', 'foo'),
|
||||
getDocNavigation({
|
||||
unversionedId: 'doc3',
|
||||
versionedId: 'doc3',
|
||||
displayedSidebar: 'foo',
|
||||
unlistedIds: new Set(),
|
||||
}),
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"Doc with ID doc3 wants to display sidebar foo but a sidebar with this name doesn't exist"`,
|
||||
);
|
||||
expect(getDocNavigation('doc3', 'doc3', 'sidebar1')).toEqual({
|
||||
expect(
|
||||
getDocNavigation({
|
||||
unversionedId: 'doc3',
|
||||
versionedId: 'doc3',
|
||||
displayedSidebar: 'sidebar1',
|
||||
unlistedIds: new Set(),
|
||||
}),
|
||||
).toEqual({
|
||||
sidebarName: 'sidebar1',
|
||||
previous: undefined,
|
||||
next: undefined,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue