docusaurus plugin auto sidebars
1.0.0
yarn add docusaurus-plugin-auto-sidebars
或者
npm install docusaurus-plugin-auto-sidebars --save
在项目的根部创建一个空的sidebars.auto.js
将此插件添加到docusaurus.config.js
中的plugins
数组:
module . exports = {
// ...
plugins : [
'docusaurus-plugin-auto-sidebars'
] ,
}
或者,如果要指定自定义docs
文件夹:
module . exports = {
// ...
plugins : [
[ 'docusaurus-plugin-auto-sidebars' , {
docs : 'mydocs'
} ]
] ,
}
只需在您的docs
文件夹中添加一个sidebars.yaml
:
- folder1 :
- Parent Folder One # First element is the title of parent, next elements are sub directories
- subfolder1 : Sub Folder One
- subfolder2 : Sub Folder Two
- subfolder3 : false # Hide it!
- folder2 :
- Parent Folder Two # First element is the title
- subfolder1 : Sub Folder One
- subfolder2 : Sub Folder Two
方法1 :通过将数字添加到文件和文件夹的开始
1.fileX.md
2.fileY.md
3.fileX.md
注意:您也可以使用负数以相反的顺序显示它们: -1. fileX.md
方法2 :在sidebars.yaml
文件中定义它们
- folder1 :
- Parent Folder One : 1 # the order number beside the title
- subfolder1 : Sub Folder One
- subfolder2 : Sub Folder Two
- folder2 :
- Parent Folder Two : 2 # the order number beside the title
- subfolder1 : Sub Folder One
- subfolder2 : Sub Folder Two