mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-21 02:27:49 +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
|
@ -5,7 +5,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import {toTagDocListProp} from '../props';
|
||||
import {toSidebarDocItemLinkProp, toTagDocListProp} from '../props';
|
||||
|
||||
describe('toTagDocListProp', () => {
|
||||
type Params = Parameters<typeof toTagDocListProp>[0];
|
||||
|
@ -61,3 +61,74 @@ describe('toTagDocListProp', () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('toSidebarDocItemLinkProp', () => {
|
||||
type Params = Parameters<typeof toSidebarDocItemLinkProp>[0];
|
||||
type Result = ReturnType<typeof toSidebarDocItemLinkProp>;
|
||||
type DocSidebarItem = Params['item'];
|
||||
type Doc = Params['doc'];
|
||||
|
||||
const id = 'some-doc-id';
|
||||
const unversionedId = 'some-unversioned-doc-id';
|
||||
|
||||
const item: DocSidebarItem = {
|
||||
type: 'doc',
|
||||
id,
|
||||
label: 'doc sidebar item label',
|
||||
};
|
||||
|
||||
const doc: Doc = {
|
||||
id,
|
||||
unversionedId,
|
||||
title: 'doc title',
|
||||
permalink: '/docPermalink',
|
||||
frontMatter: {},
|
||||
unlisted: false,
|
||||
};
|
||||
|
||||
it('works', () => {
|
||||
const result = toSidebarDocItemLinkProp({
|
||||
item,
|
||||
doc,
|
||||
});
|
||||
|
||||
expect(result).toEqual({
|
||||
type: 'link',
|
||||
docId: unversionedId,
|
||||
unlisted: false,
|
||||
label: item.label,
|
||||
autoAddBaseUrl: undefined,
|
||||
className: undefined,
|
||||
href: doc.permalink,
|
||||
customProps: undefined,
|
||||
} as Result);
|
||||
});
|
||||
|
||||
it('uses unlisted from metadata and ignores frontMatter', () => {
|
||||
expect(
|
||||
toSidebarDocItemLinkProp({
|
||||
item,
|
||||
doc: {
|
||||
...doc,
|
||||
unlisted: true,
|
||||
frontMatter: {
|
||||
unlisted: false,
|
||||
},
|
||||
},
|
||||
}).unlisted,
|
||||
).toBe(true);
|
||||
|
||||
expect(
|
||||
toSidebarDocItemLinkProp({
|
||||
item,
|
||||
doc: {
|
||||
...doc,
|
||||
unlisted: false,
|
||||
frontMatter: {
|
||||
unlisted: true,
|
||||
},
|
||||
},
|
||||
}).unlisted,
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue