📦 plugin-content-pages
Docusaurus 的默认页面插件。 此插件附带经典模板及其默认配置。 此插件提供页面创建功能。
#
安装- npm
- Yarn
npm install --save @docusaurus/plugin-content-pages
yarn add @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.
#
配置Accepted fields:
| 名称 | 类型 | 默认值 | 描述 |
| ---- | | ---- | ---- | ---- | ---- |
| path
| string
| src/pages' | 文件系统中相对于站点根目录的数据路径 此目录中的组件将被自动转换为页面。 |
|
routeBasePath|
string|
'/'| URL route for the pages section of your site. **请务必不要**添加末尾的斜杠。 |
|
include|
string[]|
['*/.{js,jsx,ts,tsx,md,mdx}] | 被这个模式匹配的文件将被包含和处理。 |
| exclude
| string[]
| 参见示例配置 | 被匹配的文件将不会有对应的路由被创建。 |
| mdxPageComponent
| string
| @theme/MDXPage'
| 每个 MDX 页面使用的组件。 |
| remarkPlugins
| []
| any[]
| 被传递给 MDX 的 Remark 插件。 |
| rehypePlugins
| []
| any []
| 被传递给 MDX 的 Rehype 插件。 |
| beforeDefaultRemarkPlugins
| any[]
| []
| 在默认的 Docusaurus Remark 插件之前被传递给 MDX 的 Remark 插件。 |
| beforeDefaultRehypePlugins
| any[]
| []
| 在默认的 Docusaurus Rehype 插件之前被传递给 MDX 的 Rehype 插件。 |
#
示例配置Here's an example configuration object.
You can provide it as preset options or plugin options.
tip
Most Docusaurus users configure this plugin through the preset options.
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('remark-math')], rehypePlugins: [], beforeDefaultRemarkPlugins: [], beforeDefaultRehypePlugins: [],};
#
Preset optionsIf you use a preset, configure this plugin through the preset options:
module.exports = { presets: [ [ '@docusaurus/preset-classic', { pages: { path: 'src/pages', // ... configuration object here }, }, ], ],};
#
Plugin optionsIf you are using a standalone plugin, provide options directly to the plugin:
module.exports = { plugins: [ [ '@docusaurus/plugin-content-pages', { path: 'src/pages', // ... configuration object here }, ], ],};
#
i18n请先阅读 i18n 简介。
#
翻译文件位置- 基础路径:
website/i18n/<语言>/docusaurus-plugin-content-pages
- 多实例路径:
website/i18n/<locale>/docusaurus-plugin-content-pages-<pluginId>
- JSON files: extracted with
docusaurus write-translations
- Markdown 文件:
website/i18n/<语言>/docusaurus-plugin-content-pages
#
文件系统结构示例website/i18n/<语言>/docusaurus-plugin-content-pages││ # website/src/pages 的译文├── first-markdown-page.md└── second-markdown-page.md