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