1、plugin-content-docs
plugin-content-docs
Provides the Docs functionality and is the default docs plugin for Docusaurus.
提供文档功能,是Docusaurus的默认文档插件。
原文
https://docusaurus.io/zh-CN/docs/api/plugins/@docusaurus/plugin-content-docs
安装
pnpm
pnpm add @docusaurus/plugin-content-docs
提示
If you use the preset @docusaurus/preset-classic
, you don't need to install this plugin as a dependency.
You can configure this plugin through the preset options.
如果您使用预设的“@docusaurus/preset-classic”,则不需要将此插件作为依赖项安装。
您可以通过[预设选项]配置此插件(https://docusaurus.io/zh-CN/docs/using-plugins#docusauruspreset-经典)。
配置
接受的字段:
参数 | 类型 | 默认值 | 描述 |
---|---|---|---|
path | string | 'docs' | 文档内容目录的文件系统路径,相对于站点目录。 |
editUrl | `string | EditUrlFunction` | undefined |
editLocalizedFiles | boolean | false | 编辑 URL 会指向本地化的文件,而不是原始的未翻译文件。 Ignored when editUrl is a function. |
editCurrentVersion | boolean | false | 编辑 URL 会永远指向当前版本文档而不是历史版本。 Ignored when editUrl is a function. |
routeBasePath | string | 'docs' | 站点文档部分的 URL 前缀。 DO NOT include a trailing slash. Use / for shipping docs without base path. |
tagsBasePath | string | 'tags' | 站点标签列表部分的 URL 前缀。 It is prepended to the routeBasePath . |
include | string[] | ['**/*.{md,mdx}'] | 相对于内容路径的 glob 模式列表,匹配到的 Markdown 文件会被构建。 |
exclude | string[] | See example configuration | Glob 模式列表,匹配到的 Markdown 文件会被排除。 Serves as refinement based on the include option. |
sidebarPath | `false | string` | undefined |
sidebarCollapsible | boolean | true | 侧边栏类别是否默认可折叠。 See also Collapsible categories |
sidebarCollapsed | boolean | true | 侧边栏类别是否默认被折叠。 See also Expanded categories by default |
sidebarItemsGenerator | SidebarGenerator | Omitted | Function used to replace the sidebar items of type 'autogenerated' with real sidebar items (docs, categories, links...). See also Customize the sidebar items generator |
numberPrefixParser | `boolean | PrefixParser` | Omitted |
docsRootComponent | string | '@theme/DocsRoot' | Parent component of all the docs plugin pages (including all versions). Stays mounted when navigation between docs pages and versions. |
docVersionRootComponent | string | '@theme/DocVersionLayout' | Parent component of all docs pages of an individual version (doc pages with sidebars, tags pages). Stays mounted when navigation between pages of that specific version. |
docRootComponent | string | '@theme/DocRoot' | Parent component of all doc pages with sidebars (regular docs pages, category generated index pages). Stays mounted when navigation between such pages. |
docItemComponent | string | '@theme/DocItem' | 文档主容器,包括了目录、页面导航等。 |
docTagsListComponent | string | '@theme/DocTagsListPage' | 标签列表页的根组件 |
docTagDocListComponent | string | '@theme/DocTagDocListPage' | 「包含某标签的所有文档」页面的根组件。 |
docCategoryGeneratedIndexComponent | string | '@theme/DocCategoryGeneratedIndexPage' | 自动生成类别索引页的根组件。 |
remarkPlugins | any[] | [] | 传递给 MDX 的 Remark 插件。 |
rehypePlugins | any[] | [] | 传递给 MDX 的 Rehype 插件。 |
rehypePlugins | any[] | [] | Recma plugins passed to MDX. |
beforeDefaultRemarkPlugins | any[] | [] | 在 Docusaurus 默认 Remark 插件之前传递给 MDX 的自定义 Remark 插件。 |
beforeDefaultRehypePlugins | any[] | [] | 在 Docusaurus 默认 Rehype 插件之前传递给 MDX 的自定义 Rehype 插件。 |
showLastUpdateAuthor | boolean | false | 是否显示最后更新文档的作者。 |
showLastUpdateTime | boolean | false | Whether to display the last date the doc was updated. This requires access to git history during the build, so will not work correctly with shallow clones (a common default for CI systems). With GitHub actions/checkout , usefetch-depth: 0 . |
breadcrumbs | boolean | true | 在文档页面上启用或禁用面包屑导航。 |
disableVersioning | boolean | false | 即使存在多个版本,也明确禁用分版功能。 这会让网站只包含当前版本。 Will error if includeCurrentVersion: false and disableVersioning: true . |
includeCurrentVersion | boolean | true | 包含文档的当前版本。 |
lastVersion | string | First version in versions.json | 文档类的导航栏项会默认显示并跳转到的文档版本。 |
onlyIncludeVersions | string[] | 所有版本 | 只包含所有可用版本中的一个子集。 |
versions | VersionsConfig | {} | 独立自定义 每个版本的属性。 |
tags | `string | false | null |
onInlineTags | `'ignore' | 'log' | 'warn' |
Types
Example configuration
Markdown前言
Markdown documents can use the following Markdown front matter metadata fields, enclosed by a line ---
on either side.
接受的字段:
参数 | 类型 | 默认值 | 描述 |
---|---|---|---|
id | string | 文件路径(包括文件夹,不含扩展名) | 文档的唯一 ID。 |
title | string | Markdown title or id | 你的文档使用的文本标题。 用于页面元数据和多个地方的备用值(侧边栏、下篇/上篇按钮……)。 如果 Markdown 内容没有标题,它会被自动添加到你的文档顶部。 |
pagination_label | string | sidebar_label or title | 这篇文档在上一篇/下一篇按钮中显示的文本 |
sidebar_label | string | title | 这篇文档在侧边栏中显示的文本 |
sidebar_position | number | 默认排序 | Controls the position of a doc inside the generated sidebar slice when using autogenerated sidebar items. See also Autogenerated sidebar metadata. |
sidebar_class_name | string | undefined | 在使用自动生成侧边栏时,给相应的侧边栏标签一个特殊类名。 |
sidebar_custom_props | object | undefined | Assign custom props to the sidebar item referencing this doc |
displayed_sidebar | string | undefined | Force the display of a given sidebar when browsing the current document. Read the multiple sidebars guide for details. |
hide_title | boolean | false | 是否隐藏文档顶部显示的标题。 此选项只会隐藏前言中定义的标题,对于 Markdown 文档顶部的标题没有任何影响。 |
hide_table_of_contents | boolean | false | 是否隐藏右侧的文档目录。 |
toc_min_heading_level | number | 2 | 目录中显示的最小标题层级。 必须介于 2 到 6 之间,并且小于等于最大值。 |
toc_max_heading_level | number | 3 | 目录中显示的最大标题层级。 必须介于 2 和 6。 |
pagination_next | `string | null` | 侧边栏的下一个文档 |
pagination_prev | `string | null` | 侧边栏的上一个文档 |
parse_number_prefixes | boolean | numberPrefixParser plugin option | 是否禁用本文档的数字前缀解析。 See also Using number prefixes. |
custom_edit_url | `string | null` | Computed using the editUrl plugin option |
keywords | string[] | undefined | 用于搜索引擎优化的文档关键词元标签。 |
description | string | Markdown 正文的第一行 | The description of your document, which will become the <meta name="description" content="..."/> and <meta property="og:description" content="..."/> in <head> , used by search engines. |
image | string | undefined | Cover or thumbnail image that will be used as the <meta property="og:image" content="..."/> in the <head> , enhancing link previews on social media and messaging platforms. |
slug | string | 文件路径 | Allows to customize the document URL (/<routeBasePath>/<slug> ). Support multiple patterns: slug: my-doc , slug: /my/path/myDoc , slug: / . |
tags | Tag[] | undefined | A list of strings or objects of two string fields label and permalink to tag to your docs. Strings can be a reference to keys of a tags file (usually tags.yml ) |
draft | boolean | false | Draft documents will only be available during development. |
unlisted | boolean | false | Unlisted documents will be available in both development and production. They will be "hidden" in production, not indexed, excluded from sitemaps, and can only be accessed by users having a direct link. |
last_update | FrontMatterLastUpdate | undefined | Allows overriding the last update author/date. Date can be any parsable date string. |
type FrontMatterLastUpdate = {date?: string; author?: string};
type Tag = string | {label: string; permalink: string};
示例:
---
id: doc-markdown
title: Docs Markdown Features
hide_title: false
hide_table_of_contents: false
sidebar_label: Markdown #这篇文档在侧边栏中显示的文本
sidebar_position: 3
pagination_label: Markdown features #这篇文档在上一篇/下一篇按钮中显示的文本
custom_edit_url: https://github.com/facebook/docusaurus/edit/main/docs/api-doc-markdown.md
description: How do I find you when I cannot solve this problem
keywords:
- docs
- docusaurus
tags: [docusaurus]
image: https://i.imgur.com/mErPwqL.png
slug: /myDoc
last_update:
date: 1/1/2000
author: custom author name
---
# Markdown Features
My Document Markdown content