📦 create-docusaurus
一个脚手架实用程序,可帮助你立即设置功能性 Docusaurus 应用。
英A scaffolding utility to help you instantly set up a functional Docusaurus app.
用法
npx create-docusaurus@latest [name] [template] [rootDir]
name
参数将用作站点的路径以及创建的应用的 package.json 中的 name
字段。 可以是绝对路径,也可以是相对于 rootDir
的路径。
英The name
argument will be used as the site's path as well as the name
field in the created app's package.json. It can be an absolute path, or a path relative to rootDir
.
template
参数可以是以下之一:
英The template
argument can be one of the following:
classic
: 使用经典模板(推荐)facebook
: 使用 Facebook/Meta 模板,其中包含一些特定于 Meta 的设置- 一个 git repo URL(以
https://
或git@
开头),可以克隆到目标 - 相对于 CWD 的本地文件路径,其中包含要复制到目标的文件
rootDir
将用于解析站点目录的绝对路径。 默认为 CWD。
英The rootDir
will be used to resolve the absolute path to the site directory. The default is CWD.
该命令最好在交互式 shell 中使用,以便所有功能都可用。
英This command should be preferably used in an interactive shell so all features are available.
选项
-t, --typescript
当模板参数是可识别的名称时使用。 目前,只有 classic
提供了 TypeScript 变体。
英Used when the template argument is a recognized name. Currently, only classic
provides a TypeScript variant.
-g, --git-strategy
当模板参数是 git 存储库时使用。 它必须是以下之一:
英Used when the template argument is a git repo. It needs to be one of:
deep
: 保留完整的 git 历史记录shallow
: 带有--depth=1
的克隆copy
: 进行浅层克隆,但不创建 git 存储库custom
: 输入你的自定义 git clone 命令。 我们会提示你。 你可以编写类似git clone --depth 10
的内容,我们将附加存储库 URL 和目标目录。
-p, --package-manager
值应为 npm
、yarn
、pnpm
或 bun
之一。 如果未明确提供,Docusaurus 将根据以下条件推断:
英Value should be one of npm
, yarn
, pnpm
, or bun
. If it's not explicitly provided, Docusaurus will infer one based on:
- 锁定文件已存在于 CWD 中(例如,如果你在现有项目中设置网站)
- 用于调用
create-docusaurus
的命令(例如npm init
、npx
、yarn create
、bunx
等) - 交互式提示,以防所有启发式都不存在
-s, --skip-install
如果提供,Docusaurus 在创建应用后不会自动安装依赖。 --package-manager
选项仅在你实际安装依赖时才有用。
英If provided, Docusaurus will not automatically install dependencies after creating the app. The --package-manager
option is only useful when you are actually installing dependencies.