mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-30 06:50:36 +02:00
feat(v2): provide doc sidebar_label through sidebars.js (#4500)
* feat : update SidebarItemDoc type * feat : update assertIsDoc * feat : allow configuring title from sidebar.js * feat : add docs * docs : refactor i18n docs to use label in sidebar.js * test : add test * Update website/docs/guides/docs/sidebar.md Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com> * docs : remove backported docs Co-authored-by: Lisa Chandra <52909743+lisa761@users.noreply.github.com> Co-authored-by: Javid <singularity.javid@gmail.com> Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com>
This commit is contained in:
parent
f7614081dd
commit
9715048f79
14 changed files with 111 additions and 11 deletions
|
@ -677,3 +677,39 @@ describe('versioned website (community)', () => {
|
|||
utils.expectSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
describe('site with doc label', () => {
|
||||
async function loadSite() {
|
||||
const siteDir = path.join(__dirname, '__fixtures__', 'site-with-doc-label');
|
||||
const context = await loadContext(siteDir);
|
||||
const sidebarPath = path.join(siteDir, 'sidebars.json');
|
||||
const plugin = pluginContentDocs(
|
||||
context,
|
||||
normalizePluginOptions(OptionsSchema, {
|
||||
path: 'docs',
|
||||
sidebarPath,
|
||||
homePageId: 'hello-1',
|
||||
}),
|
||||
);
|
||||
|
||||
const content = await plugin.loadContent();
|
||||
|
||||
return {content};
|
||||
}
|
||||
|
||||
test('label in sidebar.json is used', async () => {
|
||||
const {content} = await loadSite();
|
||||
const loadedVersion = content.loadedVersions[0];
|
||||
const sidebarProps = toSidebarsProp(loadedVersion);
|
||||
|
||||
expect(sidebarProps.docs[0].label).toBe('Hello One');
|
||||
});
|
||||
|
||||
test('sidebar_label in doc has higher precedence over label in sidebar.json', async () => {
|
||||
const {content} = await loadSite();
|
||||
const loadedVersion = content.loadedVersions[0];
|
||||
const sidebarProps = toSidebarsProp(loadedVersion);
|
||||
|
||||
expect(sidebarProps.docs[1].label).toBe('Hello 2 From Doc');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue