Docusaurus 配置多个文档
修改 docusaurus.config.js
增加如下配置节:
module.exports = {
// ...
/**
* 增加文档栏目
*/
plugins: [
[
"@docusaurus/plugin-content-docs",
{
id: "doc-articles", // 唯一标识
path: "src/docs/articles", // 根据实际情况修改文档目录
routeBasePath: "docs/articles", // 文档的URL路径
sidebarPath: "./sidebars.js", // 文档侧边栏模块
editUrl: editUrl, // 编辑连接
showLastUpdateTime: true, // 显示最后更新时间
// docLayoutComponent: '@theme/DocPage',
// docItemComponent: '@theme/DocItem'
},
],
// 第二个文档
[
"@docusaurus/plugin-content-docs",
{
id: "doc-reading",
path: "src/docs/reading",
routeBasePath: "docs/reading",
sidebarPath: "./sidebars.js",
showLastUpdateTime: true,
},
]
];
// ...
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
// ...
navbar: {
/**
* 顶部导航条增加入口连接
*/
items: [
// 本次新增的两个文档入口
{ to: 'docs/articles', label: 'Articles', position: 'left' },
{ to: 'docs/reading', label: 'Reading', position: 'left' },
// 其他现有链接
{ to: 'blog', label: 'Blog', position: 'left' },
{
to: 'docs/built-in',
activeBasePath: 'docs/built-in',
label: 'Documents',
position: 'left',
},
{
href: 'https://github.com/alanwei43',
label: 'GitHub',
position: 'right',
},
],
},
// ...
}),
}