自动迁移
¥Automated migration
迁移 CLI 会自动将你的 v1 网站迁移到 v2 网站。
¥The migration CLI automatically migrates your v1 website to a v2 website.
使用迁移 CLI 后仍然需要手动工作,因为我们无法自动执行完整迁移
¥Manual work is still required after using the migration CLI, as we can't automate a full migration
迁移 CLI 迁移:
¥The migration CLI migrates:
-
站点配置(从
siteConfig.js
到docusaurus.config.js
)¥Site configurations (from
siteConfig.js
todocusaurus.config.js
) -
package.json
-
sidebars.json
-
/docs
-
/blog
-
/static
-
versioned_sidebar.json
和/versioned_docs
(如果你的站点使用版本控制)¥
versioned_sidebar.json
and/versioned_docs
if your site uses versioning
要使用迁移 CLI,请执行以下步骤:
¥To use the migration CLI, follow these steps:
-
在使用迁移 CLI 之前,请确保
/docs
、/blog
、/static
、sidebars.json
、siteConfig.js
、package.json
遵循预期结构。¥Before using the migration CLI, ensure that
/docs
,/blog
,/static
,sidebars.json
,siteConfig.js
,package.json
follow the expected structure. -
要迁移 v1 网站,请使用适当的文件系统路径运行迁移 CLI:
¥To migrate your v1 website, run the migration CLI with the appropriate filesystem paths:
# migration command format
npx @docusaurus/migrate migrate <v1 website directory> <desired v2 website directory>
# example
npx @docusaurus/migrate migrate ./v1-website ./v2-website
-
要在本地查看你的新网站,请进入你的 v2 网站目录并启动你的开发服务器。
¥To view your new website locally, go into your v2 website's directory and start your development server.
- npm
- Yarn
- pnpm
cd ./v2-website
npm install
npm start
cd ./v2-website
yarn install
yarn start
cd ./v2-website
pnpm install
pnpm start
迁移 CLI 更新现有文件。一定要先提交它们!
¥The migration CLI updates existing files. Be sure to have committed them first!
选项
¥Options
你可以向迁移 CLI 添加选项标志,以自动将 Markdown 内容和页面迁移到 v2。你可能仍然需要进行一些手动更改才能达到你想要的结果。
¥You can add option flags to the migration CLI to automatically migrate Markdown content and pages to v2. It is likely that you will still need to make some manual changes to achieve your desired result.
名称 | 描述 |
---|---|
--mdx | 添加此标志以自动将 Markdown 转换为 MDX |
--page | 添加此标志以自动迁移页面 |
# example using options
npx @docusaurus/migrate migrate --mdx --page ./v1-website ./v2-website
页面和 MDX 的迁移仍在进行中。
¥The migration of pages and MDX is still a work in progress.
我们建议你尝试在没有这些选项的情况下运行页面,提交,然后尝试使用 --page
和 --mdx
选项再次运行迁移。
¥We recommend you to try to run the pages without these options, commit, and then try to run the migration again with the --page
and --mdx
options.
这样,你就可以轻松检查并修复差异。
¥This way, you'd be able to easily inspect and fix the diff.