侧边栏
创建侧边栏可以:
- Group multiple related documents
- Display a sidebar on each of those documents
- Provide paginated navigation, with next/previous button
要在你的 Docusaurus 网站上使用侧边栏,只需两步:
- Define a file that exports a dictionary of sidebar objects.
- Pass this object into the
@docusaurus/plugin-docs
plugin directly or via@docusaurus/preset-classic
.
docusaurus.config.js
module.exports = {
presets: [
[
'@docusaurus/preset-classic',
{
docs: {
sidebarPath: require.resolve('./sidebars.js'),
},
},
],
],
};
这个章节是文档侧边栏功能的一个总览。 在接下来的章节中,我们会系统地介绍下列概念:
📄️ 侧边栏项目
We have introduced three types of item types in the example in the previous section autogenerated, which we will explain in detail later.
📄️ 自动生成侧边栏
Docusaurus can create a sidebar automatically from your filesystem structure: each folder creates a sidebar category, and each file creates a doc link.
📄️ 使用多个侧边栏
You can create a sidebar for each set of Markdown files that you want to group together.
Default sidebar
If the sidebarPath
is unspecified, Docusaurus automatically generates a sidebar for you, by using the filesystem structure of the docs
folder:
sidebars.js
module.exports = {
mySidebar: [
{
type: 'autogenerated',
dirName: '.', // generate sidebar from the docs folder (or versioned_docs/<version>)
},
],
};
你也可以显式定义你的侧边栏。