feat(v2): allow user to customize/enhance the default sidebar items generator (#4658)

* allow and document how to wrap/enhance the default docusaurus sidebar items generator

* improve doc

* doc

* doc
This commit is contained in:
Sébastien Lorber 2021-04-21 18:35:03 +02:00 committed by GitHub
parent e11597aba9
commit 792f4ac6fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 250 additions and 50 deletions

View file

@ -76,14 +76,25 @@ module.exports = {
* Function used to replace the sidebar items of type "autogenerated"
* by real sidebar items (docs, categories, links...)
*/
sidebarItemsGenerator: function ({
item,
version,
docs,
numberPrefixParser,
sidebarItemsGenerator: async function ({
defaultSidebarItemsGenerator, // useful to re-use/enhance default sidebar generation logic from Docusaurus
numberPrefixParser, // numberPrefixParser configured for this plugin
item, // the sidebar item with type "autogenerated"
version, // the current version
docs, // all the docs of that version (unfiltered)
}) {
// Use the provided data to create a custom "sidebar slice"
return [{type: 'doc', id: 'doc1'}];
// Use the provided data to generate a custom sidebar slice
return [
{type: 'doc', id: 'intro'},
{
type: 'category',
label: 'Tutorials',
items: [
{type: 'doc', id: 'tutorial1'},
{type: 'doc', id: 'tutorial2'},
],
},
];
},
/**
* The Docs plugin supports number prefixes like "01-My Folder/02.My Doc.md".