📦 plugin-content-docs
Provides the Docs functionality and is the default docs plugin for Docusaurus.
Installation
- npm
- Yarn
- pnpm
npm install --save @docusaurus/plugin-content-docs
yarn add @docusaurus/plugin-content-docs
pnpm add @docusaurus/plugin-content-docs
tip
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.
Configuration
Campos aceitos:
Nome | Type | Padrão | Descrição |
---|---|---|---|
path | string | 'docs' | Path to the docs content directory on the file system, relative to site directory. |
editUrl | string | EditUrlFunction | undefined | Base URL to edit your site. The final URL is computed by editUrl + relativeDocPath . Using a function allows more nuanced control for each file. Omitting this variable entirely will disable edit links. |
editLocalizedFiles | boolean | false | The edit URL will target the localized file, instead of the original unlocalized file. Ignored when editUrl is a function. |
editCurrentVersion | boolean | false | The edit URL will always target the current version doc instead of older versions. Ignored when editUrl is a function. |
routeBasePath | string | 'docs' | URL route for the docs section of your site. DO NOT include a trailing slash. Use / for shipping docs without base path. |
tagsBasePath | string | 'tags' | URL route for the tags list page of your site. It is prepended to the routeBasePath . |
include | string[] | ['**/*.{md,mdx}'] | Array of glob patterns matching Markdown files to be built, relative to the content path. |
exclude | string[] | See example configuration | Array of glob patterns matching Markdown files to be excluded. Serves as refinement based on the include option. |
sidebarPath | false | string | undefined | Path to sidebar configuration. Use false to disable sidebars, or undefined to create a fully autogenerated sidebar. |
sidebarCollapsible | boolean | true | Whether sidebar categories are collapsible by default. See also Collapsible categories |
sidebarCollapsed | boolean | true | Whether sidebar categories are collapsed by default. 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 | Custom parsing logic to extract number prefixes from file names. Use false to disable this behavior and leave the docs untouched, and true to use the default parser. See also Using number prefixes |
docLayoutComponent | string | '@theme/DocPage' | Root layout component of each doc page. Provides the version data context, and is not unmounted when switching docs. |
docItemComponent | string | '@theme/DocItem' | Main doc container, with TOC, pagination, etc. |
docTagsListComponent | string | '@theme/DocTagsListPage' | Root component of the tags list page |
docTagDocListComponent | string | '@theme/DocTagDocListPage' | Root component of the "docs containing tag X" page. |
docCategoryGeneratedIndexComponent | string | '@theme/DocCategoryGeneratedIndexPage' | Root component of the generated category index page. |
remarkPlugins | any[] | [] | Remark plugins passed to MDX. |
rehypePlugins | any[] | [] | Rehype plugins passed to MDX. |
beforeDefaultRemarkPlugins | any[] | [] | Custom Remark plugins passed to MDX before the default Docusaurus Remark plugins. |
beforeDefaultRehypePlugins | any[] | [] | Custom Rehype plugins passed to MDX before the default Docusaurus Rehype plugins. |
showLastUpdateAuthor | boolean | false | Whether to display the author who last updated the doc. |
showLastUpdateTime | boolean | false | Whether to display the last date the doc was updated. |
breadcrumbs | boolean | true | Enable or disable the breadcrumbs on doc pages. |
disableVersioning | boolean | false | Explicitly disable versioning even when multiple versions exist. This will make the site only include the current version. Will error if includeCurrentVersion: false and disableVersioning: true . |
includeCurrentVersion | boolean | true | Include the current version of your docs. |
lastVersion | string | First version in versions.json | The version navigated to in priority and displayed by default for docs navbar items. |
onlyIncludeVersions | string[] | All versions available | Only include a subset of all available versions. |
versions | VersionsConfig | {} | Independent customization of each version's properties. |
Types
EditUrlFunction
type EditUrlFunction = (params: {
version: string;
versionDocsDirPath: string;
docPath: string;
permalink: string;
locale: string;
}) => string | undefined;
PrefixParser
type PrefixParser = (filename: string) => {
filename: string;
numberPrefix?: number;
};