是否可以根据您所在网站的哪个部分显示不同的侧边栏?因此,如果我有两个部分(Books
和Countries
),那么我可以显示相应的侧边栏菜单对象:
module.exports = {
books: {
"Children's Book": [
"books/childrens-books/winnie-the-pooh",
"books/childrens-books/harry-potter",
],
"Non-Fiction": [
"books/non-fiction/hitchikers-guide",
"books/non-fiction/a-history-of-england",
]
},
countries: {
"Europe": [
"countries/europe/england",
"countries/europe/france",
"countries/europe/spain",
],
"Asia": [
"countries/asia/china",
"countries/asia/india",
"countries/asia/laos",
],
},
}
文档确实提到可以做这样的事情,但没有任何例子可以做:
通过向导出的对象添加更多顶级键,您可以为不同的 Markdown 文件创建多个侧边栏。
我可以找到引用的侧边栏的唯一其他地方是 in docusaurus.config.js
,但我不确定此部分的用途:
presets: [
[
'@docusaurus/preset-classic',
{
docs: {
sidebarPath: require.resolve('./sidebars.js'),
},
...
任何指针表示赞赏!