mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-18 19:46:57 +02:00
Co-authored-by: Joshua Chen <sidachen2003@gmail.com> Co-authored-by: Joey Clover <joey@popos.local> Co-authored-by: reece-white <93522192+reece-white@users.noreply.github.com> Co-authored-by: Shreesh Nautiyal <114166000+Shreesh09@users.noreply.github.com> Co-authored-by: Nick Gerleman <nick@nickgerleman.com> Co-authored-by: Chongyi Zheng <git@zcy.dev> Co-authored-by: MCR Studio <99176216+mcrstudio@users.noreply.github.com> Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com> Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com> Co-authored-by: Ivan Mar (sOkam!) <7308253+heysokam@users.noreply.github.com> Co-authored-by: c0h1b4 <dwidman@gmail.com> Co-authored-by: Janessa Garrow <janessa.garrow@gmail.com> Co-authored-by: ozaki <29860391+OzakIOne@users.noreply.github.com> Co-authored-by: axmmisaka <6500159+axmmisaka@users.noreply.github.com> Co-authored-by: Tatsunori Uchino <tats.u@live.jp> Co-authored-by: Simen Bekkhus <sbekkhus91@gmail.com> Co-authored-by: Sanjaiyan Parthipan <parthipankalayini@gmail.com> Co-authored-by: Jack Robson <143492403+jack-robson@users.noreply.github.com> Co-authored-by: dawei-wang <dawei-wang@users.noreply.github.com> Co-authored-by: eitsupi <50911393+eitsupi@users.noreply.github.com> fix(create-docusaurus): fix readme docusaurus 2 ref (#9487) fix(theme): fix firefox CSS :has() support bug (#9530) fix(theme): docs html sidebar items should always be visible (#9531) fix: v3 admonitions should support v2 title syntax for nested admonitions (#9535) fix(theme-classic): fixed wrong cursor on dropdown menu in navbar, when window is small (#9398) fix(theme): upgrade prism-react-renderer, fix html script and style tag highlighting (#9567) fix: add v2 retrocompatible support for quoted admonitions (#9570) fix(i18n): complete translations for theme-common.json Brazilian Portuguese (pt-BR) (#9477) fix(content-blog): add baseUrl for author.image_url (#9581) fix(type-aliases): add `title` prop for imported inline SVG React components (#9612) fix(utils): Markdown link replacement with <> but no spaces (#9617) fix(live-codeblock): stabilize react-live transformCode callback, fix editor/preview desync (#9631) fix(cli): output help when no conventional config + no subcommand (#9648) fix CI job (#9604) fix Lint Autofix workflow (#9632) fix(pwa-plugin): upgrade workbox (#9668) fix(create-docusaurus): fix init template code blocks, and little improvements (#9696) fix(theme): allow empty code blocks and live playgrounds (#9704) fix(core): various broken anchor link fixes (#9732) fix: remove old useless mdx typedefs (#9733) fix(theme-common): fix missing code block MagicComments style in Visual Basic (.NET) 16 (#9727) fix(core): conditionally include `hostname` parameter when using… (#9407) fix(create-docusaurus): fix typo in init template sample docs (#9783) fix(mdx-loader): allow spaces before `mdx-code-block` info string (#9776) fix(core): links with target "_blank" should no be checked by the broken link checker (#9788) fix(core): broken links optimization behaves differently than non-optimized logic (#9791)
140 lines
5 KiB
Text
140 lines
5 KiB
Text
---
|
|
sidebar_position: 3
|
|
slug: /api/plugins/@docusaurus/plugin-content-pages
|
|
---
|
|
|
|
# 📦 plugin-content-pages
|
|
|
|
import APITable from '@site/src/components/APITable';
|
|
|
|
The default pages plugin for Docusaurus. The classic template ships with this plugin with default configurations. This plugin provides [creating pages](guides/creating-pages.mdx) functionality.
|
|
|
|
## Installation {#installation}
|
|
|
|
```bash npm2yarn
|
|
npm install --save @docusaurus/plugin-content-pages
|
|
```
|
|
|
|
:::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](../../using-plugins.mdx#docusauruspreset-classic).
|
|
|
|
:::
|
|
|
|
## Configuration {#configuration}
|
|
|
|
Accepted fields:
|
|
|
|
```mdx-code-block
|
|
<APITable>
|
|
```
|
|
|
|
| Name | Type | Default | Description |
|
|
| --- | --- | --- | --- |
|
|
| `path` | `string` | `'src/pages'` | Path to data on filesystem relative to site dir. Components in this directory will be automatically converted to pages. |
|
|
| `routeBasePath` | `string` | `'/'` | URL route for the pages section of your site. **DO NOT** include a trailing slash. |
|
|
| `include` | `string[]` | `['**/*.{js,jsx,ts,tsx,md,mdx}']` | Matching files will be included and processed. |
|
|
| `exclude` | `string[]` | _See example configuration_ | No route will be created for matching files. |
|
|
| `mdxPageComponent` | `string` | `'@theme/MDXPage'` | Component used by each MDX 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. |
|
|
|
|
```mdx-code-block
|
|
</APITable>
|
|
```
|
|
|
|
### Example configuration {#ex-config}
|
|
|
|
You can configure this plugin through preset options or plugin options.
|
|
|
|
:::tip
|
|
|
|
Most Docusaurus users configure this plugin through the preset options.
|
|
|
|
:::
|
|
|
|
```js config-tabs
|
|
// Preset Options: pages
|
|
// Plugin Options: @docusaurus/plugin-content-pages
|
|
|
|
const config = {
|
|
path: 'src/pages',
|
|
routeBasePath: '',
|
|
include: ['**/*.{js,jsx,ts,tsx,md,mdx}'],
|
|
exclude: [
|
|
'**/_*.{js,jsx,ts,tsx,md,mdx}',
|
|
'**/_*/**',
|
|
'**/*.test.{js,jsx,ts,tsx}',
|
|
'**/__tests__/**',
|
|
],
|
|
mdxPageComponent: '@theme/MDXPage',
|
|
remarkPlugins: [require('./my-remark-plugin')],
|
|
rehypePlugins: [],
|
|
beforeDefaultRemarkPlugins: [],
|
|
beforeDefaultRehypePlugins: [],
|
|
};
|
|
```
|
|
|
|
## Markdown front matter {#markdown-front-matter}
|
|
|
|
Markdown pages can use the following Markdown [front matter](../../guides/markdown-features/markdown-features-intro.mdx#front-matter) metadata fields, enclosed by a line `---` on either side.
|
|
|
|
Accepted fields:
|
|
|
|
```mdx-code-block
|
|
<APITable>
|
|
```
|
|
|
|
| Name | Type | Default | Description |
|
|
| --- | --- | --- | --- |
|
|
| `title` | `string` | Markdown title | The blog post title. |
|
|
| `description` | `string` | The first line of Markdown content | The description of your page, which will become the `<meta name="description" content="..."/>` and `<meta property="og:description" content="..."/>` in `<head>`, used by search engines. |
|
|
| `keywords` | `string[]` | `undefined` | Keywords meta tag, which will become the `<meta name="keywords" content="keyword1,keyword2,..."/>` in `<head>`, used by search engines. |
|
|
| `image` | `string` | `undefined` | Cover or thumbnail image that will be used when displaying the link to your post. |
|
|
| `wrapperClassName` | `string` | | Class name to be added to the wrapper element to allow targeting specific page content. |
|
|
| `hide_table_of_contents` | `boolean` | `false` | Whether to hide the table of contents to the right. |
|
|
| `draft` | `boolean` | `false` | Draft pages will only be available during development. |
|
|
| `unlisted` | `boolean` | `false` | Unlisted pages 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. |
|
|
|
|
```mdx-code-block
|
|
</APITable>
|
|
```
|
|
|
|
Example:
|
|
|
|
```md
|
|
---
|
|
title: Markdown Page
|
|
description: Markdown page SEO description
|
|
wrapperClassName: markdown-page
|
|
hide_table_of_contents: false
|
|
draft: true
|
|
---
|
|
|
|
Markdown page content
|
|
```
|
|
|
|
## i18n {#i18n}
|
|
|
|
Read the [i18n introduction](../../i18n/i18n-introduction.mdx) first.
|
|
|
|
### Translation files location {#translation-files-location}
|
|
|
|
- **Base path**: `website/i18n/[locale]/docusaurus-plugin-content-pages`
|
|
- **Multi-instance path**: `website/i18n/[locale]/docusaurus-plugin-content-pages-[pluginId]`
|
|
- **JSON files**: extracted with [`docusaurus write-translations`](../../cli.mdx#docusaurus-write-translations-sitedir)
|
|
- **Markdown files**: `website/i18n/[locale]/docusaurus-plugin-content-pages`
|
|
|
|
### Example file-system structure {#example-file-system-structure}
|
|
|
|
```bash
|
|
website/i18n/[locale]/docusaurus-plugin-content-pages
|
|
│
|
|
│ # translations for website/src/pages
|
|
├── first-markdown-page.md
|
|
└── second-markdown-page.md
|
|
```
|