RTMP
Docusaurus 可以管理文档的多个版本。
创建文档版本
发布项目的 1.0 版本:
npm run docusaurus docs:version 1.0
docs 文件夹会被复制到 versioned_docs/version-1.0,同时会创建 versions.json。
现在文档包含两个版本:
1.0:位于http://localhost:3000/docs/,对应 1.0 版本文档current:位于http://localhost:3000/docs/next/,对应即将发布但尚未发布的文档
添加版本下拉菜单
要在不同版本之间顺畅切换,请添加版本下拉菜单。
修改 docusaurus.config.js 文件:
docusaurus.config.js
export default {
themeConfig: {
navbar: {
items: [
{
type: 'docsVersionDropdown',
},
],
},
},
};
文档版本下拉菜单会显示在导航栏中:

更新现有版本
可以直接编辑相应目录中的版本化文档:
- 修改
versioned_docs/version-1.0/hello.md会更新http://localhost:3000/docs/hello - 修改
docs/hello.md会更新http://localhost:3000/docs/next/hello