I want to write a plugin that will update the sidebar.js
I'm planning to write a plugin for docusaurus that will look to my components and generate the docs automatically using react-docgen. So I need a way to update the sidebar using this plugin.
Yes - having the sidebar auto-generate based on the content, folder/file structure in /docs etc. would make content management so much easier.
@mnbf9rca Try this plugin, i've just published it to npm
https://github.com/acrobit/docusaurus-plugin-auto-sidebars
You can override the name or the order of folders in the sidebars.yaml file.
Plugins lifecycles are generic across the whole website, not coupled to any plugin, such as docs. So it wouldn't make sense to add a plugin lifecycle for updating sidebars. We either need to modify the existing docs plugin or something or build an entirely new docs plugin.
Alternatively, we could add a plugin lifecycle called initialization() where you can write your own code to generate a sidebars.js file, but you can easily add a command that does that yourself before you run yarn start/build in package.json.
{
"scripts": {
"start": "./generate-sidebars.js && docusaurus start",
"build": "./generate-sidebars.js && docusaurus build"
}
}
Most helpful comment
Yes - having the sidebar auto-generate based on the content, folder/file structure in /docs etc. would make content management so much easier.