管理文档版本
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/hellodocs/hello.md更新http://localhost:3000/docs/next/hello