mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-09 14:22:27 +02:00
Merge branch 'main' into ozaki/showcase
This commit is contained in:
commit
01657b0744
249 changed files with 24910 additions and 3445 deletions
|
@ -18,6 +18,12 @@ Refer to the Getting Started [**Configuration**](../configuration.mdx) for examp
|
|||
|
||||
`docusaurus.config.js` contains configurations for your site and is placed in the root directory of your site.
|
||||
|
||||
:::note
|
||||
|
||||
With a [TypeScript](../typescript-support.mdx) Docusaurus codebase your config file may be called `docusaurus.config.ts`. The syntax is broadly identical to the `js` config file with the addition of types. You can see an example on the [Docusaurus Website](https://github.com/facebook/docusaurus/blob/main/website/docusaurus.config.ts) itself.
|
||||
|
||||
:::
|
||||
|
||||
This file is run in Node.js and should export a site configuration object, or a function that creates it.
|
||||
|
||||
The `docusaurus.config.js` file supports:
|
||||
|
@ -438,6 +444,10 @@ export type ParseFrontMatter = (params: {
|
|||
content: string;
|
||||
}>;
|
||||
|
||||
type MarkdownAnchorsConfig = {
|
||||
maintainCase: boolean;
|
||||
};
|
||||
|
||||
type MarkdownConfig = {
|
||||
format: 'mdx' | 'md' | 'detect';
|
||||
mermaid: boolean;
|
||||
|
@ -445,6 +455,7 @@ type MarkdownConfig = {
|
|||
parseFrontMatter?: ParseFrontMatter;
|
||||
mdx1Compat: MDX1CompatOptions;
|
||||
remarkRehypeOptions: object; // see https://github.com/remarkjs/remark-rehype#options
|
||||
anchors: MarkdownAnchorsConfig;
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -469,6 +480,9 @@ export default {
|
|||
admonitions: true,
|
||||
headingIds: true,
|
||||
},
|
||||
anchors: {
|
||||
maintainCase: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
|
@ -484,6 +498,7 @@ export default {
|
|||
| `preprocessor` | `MarkdownPreprocessor` | `undefined` | Gives you the ability to alter the Markdown content string before parsing. Use it as a last-resort escape hatch or workaround: it is almost always better to implement a Remark/Rehype plugin. |
|
||||
| `parseFrontMatter` | `ParseFrontMatter` | `undefined` | Gives you the ability to provide your own front matter parser, or to enhance the default parser. Read our [front matter guide](../guides/markdown-features/markdown-features-intro.mdx#front-matter) for details. |
|
||||
| `mdx1Compat` | `MDX1CompatOptions` | `{comments: true, admonitions: true, headingIds: true}` | Compatibility options to make it easier to upgrade to Docusaurus v3+. |
|
||||
| `anchors` | `MarkdownAnchorsConfig` | `{maintainCase: false}` | Options to control the behavior of anchors generated from Markdown headings |
|
||||
| `remarkRehypeOptions` | `object` | `undefined` | Makes it possible to pass custom [`remark-rehype` options](https://github.com/remarkjs/remark-rehype#options). |
|
||||
|
||||
```mdx-code-block
|
||||
|
|
|
@ -44,11 +44,24 @@ Accepted fields:
|
|||
| `priority` | `number \| null` | `0.5` | See [sitemap docs](https://www.sitemaps.org/protocol.html#xmlTagDefinitions) |
|
||||
| `ignorePatterns` | `string[]` | `[]` | A list of glob patterns; matching route paths will be filtered from the sitemap. Note that you may need to include the base URL in here. |
|
||||
| `filename` | `string` | `sitemap.xml` | The path to the created sitemap file, relative to the output directory. Useful if you have two plugin instances outputting two files. |
|
||||
| `createSitemapItems` | <code>[CreateSitemapItemsFn](#CreateSitemapItemsFn) \| undefined</code> | `undefined` | An optional function which can be used to transform and / or filter the items in the sitemap. |
|
||||
|
||||
```mdx-code-block
|
||||
</APITable>
|
||||
```
|
||||
|
||||
### Types {#types}
|
||||
|
||||
#### `CreateSitemapItemsFn` {#CreateSitemapItemsFn}
|
||||
|
||||
```ts
|
||||
type CreateSitemapItemsFn = (params: {
|
||||
siteConfig: DocusaurusConfig;
|
||||
routes: RouteConfig[];
|
||||
defaultCreateSitemapItems: CreateSitemapItemsFn;
|
||||
}) => Promise<SitemapItem[]>;
|
||||
```
|
||||
|
||||
:::info
|
||||
|
||||
This plugin also respects some site config:
|
||||
|
@ -86,6 +99,11 @@ const config = {
|
|||
priority: 0.5,
|
||||
ignorePatterns: ['/tags/**'],
|
||||
filename: 'sitemap.xml',
|
||||
createSitemapItems: async (params) => {
|
||||
const {defaultCreateSitemapItems, ...rest} = params;
|
||||
const items = await defaultCreateSitemapItems(rest);
|
||||
return items.filter((item) => !item.url.includes('/page/'));
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue