跳转至主内容
Version: 2.0.0-beta.5 🚧

文档简介

文档功能可让您以层级格式组织编排 Markdown 文件。

信息

Check the Docs Plugin API Reference documentation for an exhaustive list of options.

文档标识符#

每个文档均有唯一的 id (标识符)。 默认情况下,文档 id 是相对根文档目录的文件名称 (除文件名)。

例如,greeting.md 的标识符是 greeting,而 guide/hello.md 的标识符则是 guide/hello

website # 您网站的根目录└── docs   ├── greeting.md   └── guide      └── hello.md

但是,id最后一部分可被用户预先指定。 举个例子,如果 guide/hello.md' 的内容为如下所示,其最终的 id 则为 guide/part1

---id: part1---Lorem ipsum

若您想要调整文档 URL,您还可以添加 slug 字段 (默认与 id 相同)。

---id: part1slug: part1.html---Lorem ipsum
note

您可以使用:

  • 绝对路径:slug: /mySlugslug: /...
  • 相对路径:slug: mySlugslug: ./../mySlug...

首页文档#

若您想要文档位于根目录下,并使得路径形如 https://docusaurus.io/docs/,则可按以下示例填写前言中的 slug:

---id: my-home-docslug: /---Lorem ipsum

仅文档模式#

若您仅想使用 Docusaurus 2 的文档功能,您可让其使用文档页面作为首页。

To enable docs-only mode, set the docs plugin routeBasePath: '/', and use the frontmatter slug: / on the document that should be the index page (more info).

caution

您应该在之后删除 ./src/pages/index.js 中的已有首页,否则两个文件均将映射到相同的路径!

tip

Docusaurus 2 中还存在 ”仅博客模式“。 您可以使用上述的方法切换。 请前往仅博客模式来了解如何配置。