yarn add docusaurus-plugin-sidebarAdd plugin:
module.exports = {
plugins: [require.resolve('docusaurus-plugin-sidebar')],
}Options:
module.exports = {
plugins: [
[
require.resolve('docusaurus-plugin-sidebar'),
{
dir: 'sidebar', // default sidebar directory
file: 'sidebars.js' // default sidebar file
}
]
],
}Create a sidebar directory:
mkdir sidebarCreate sidebar item files
vi sidebar/basic.ymlsomeSidebar:
- Docusaurus:
- doc1
- doc2
- doc3
- Features:
- mdx$ yarn start
$ yarn build
- doc- ref: doc- name: Link Name
link: https://example.com- upper category:
- doc1
- ref: doc2
- name: Link Name
link: https://example.com
- category:
- sub category:
- doc3
- doc4This is not the original option for docusaurus; it is easy to use when there are many documents.
There are three types.
- All files in the directory will be included, in alphabetical order.
- Category Name: path/to/dir- You can also select files from the directory.
- Category Name: path/to/dir
items:
- doc1
- doc2
- doc5
- doc4- If it leaves as the empty value, top directory (
docs) documents are included. It is easier to know if you set it as an empty string.
- Category Name:
- Category Name: ''Look at the example code.