docs: document siteConfig.markdown + better mdx-loader retrocompat (#8419)

This commit is contained in:
Sébastien Lorber 2022-12-07 17:59:51 +01:00 committed by GitHub
parent 681e6d3ea4
commit 59fac0b1d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 1 deletions

View file

@ -44,3 +44,16 @@ Array of remark plugins to manipulate the MDXAST
### `metadataPath`
A function to provide the metadataPath depending on current loaded MDX path that will be exported as the MDX metadata.
### `markdownConfig`
The global Docusaurus Markdown config (`config.markdown`), that plugin authors should forward:
```js
const loader = {
loader: require.resolve('@docusaurus/mdx-loader'),
options: {
markdownConfig: siteConfig.markdown,
},
};
```

View file

@ -173,7 +173,7 @@ export async function mdxLoader(
...(reqOptions.beforeDefaultRemarkPlugins ?? []),
...getAdmonitionsPlugins(reqOptions.admonitions ?? false),
...DEFAULT_OPTIONS.remarkPlugins,
...(reqOptions.markdownConfig.mermaid ? [mermaid] : []),
...(reqOptions.markdownConfig?.mermaid ? [mermaid] : []),
[
transformImage,
{

View file

@ -394,6 +394,30 @@ module.exports = {
};
```
### `markdown` {#markdown}
The global Docusaurus Markdown config.
- Type: `MarkdownConfig`
```ts
type MarkdownConfig = {
mermaid: boolean;
};
```
Example:
```js title="docusaurus.config.js"
module.exports = {
markdown: {
mermaid: true,
},
};
```
- `mermaid`: when `true`, allows Docusaurus to render Markdown code blocks with `mermaid` language as Mermaid diagrams.
### `customFields` {#customFields}
Docusaurus guards `docusaurus.config.js` from unknown fields. To add a custom field, define it on `customFields`.