自动化迁移
迁移CLI自动将您的v1网站迁移到v2网站。
info
使用迁移CLI后仍需要手动工作,因为我们无法自动化完整的迁移
迁移CLI迁移:
- 站点配置(从
siteConfig.js到docusaurus.config.js) package.jsonsidebars.json/docs/blog/staticversioned_sidebar.json和/versioned_docs如果你的网站使用了版本控制
要使用迁移CLI,请按照以下步骤操作:
-
在使用迁移CLI之前,请确保
/docs、/blog、/static、sidebars.json、siteConfig.js、package.json遵循预期的结构。 -
要迁移您的v1网站,请使用适当的文件系统路径运行迁移CLI:
# migration command format
npx @docusaurus/migrate migrate <v1 website directory> <desired v2 website directory>
# example
npx @docusaurus/migrate migrate ./v1-website ./v2-website
- 要在本地查看您的新网站,请进入您的v2网站目录并启动您的开发服务器。
- npm
- Yarn
- pnpm
cd ./v2-website
npm install
npm start
cd ./v2-website
yarn install
yarn start
cd ./v2-website
pnpm install
pnpm start
danger
迁移CLI会更新现有文件。请确保首先提交它们!
选项
你可以向迁移CLI添加选项标志,以自动将Markdown内容和页面迁移到v2。你可能仍然需要进行一些手动更改以达到你想要的结果。
| Name | Description |
|---|---|
--mdx | Add this flag to convert Markdown to MDX automatically |
--page | Add this flag to migrate pages automatically |
# example using options
npx @docusaurus/migrate migrate --mdx --page ./v1-website ./v2-website
danger
页面和MDX的迁移仍在进行中。
我们建议您尝试在没有这些选项的情况下运行页面,提交,然后尝试使用--page和--mdx选项再次运行迁移。
这样,您将能够轻松检查和修复差异。