跳到主要内容
版本:Next

管理文档版本

Docusaurus可以管理多个版本的文档。

创建文档版本​

发布您项目的 1.0 版本:

npm run docusaurus docs:version 1.0

docs文件夹已复制到versioned_docs/version-1.0和versions.json中。

您的文档现在有两个版本:

  • 1.0 at http://localhost:3000/docs/ 版本1.0 docs
  • current in http://localhost:3000/docs/next/ for the Upping, unreleased docs

添加版本下拉列表​

若要无缝地跨越版本导航,请添加一个版本下拉。

修改docusaurus.config.js文件:

docusaurus.config.js
export default {
themeConfig: {
navbar: {
items: [
{
type: 'docsVersionDropdown',
},
],
},
},
};

下拉文档版本出现在您的导航栏:

Docs 版本下拉

更新现有版本​

可以在其各自的文件夹中编辑版本文档:

  • versioned_docs/version-1.0/hello.md更新http://localhost:3000/docs/hello
  • docs/hello.md 更新http://localhost:3000/docs/next/hello