Skip to content

Commit

Permalink
docs: document siteConfig.markdown + better mdx-loader retrocompat (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Dec 7, 2022
1 parent 681e6d3 commit 59fac0b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
13 changes: 13 additions & 0 deletions packages/docusaurus-mdx-loader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
};
```
2 changes: 1 addition & 1 deletion packages/docusaurus-mdx-loader/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
{
Expand Down
24 changes: 24 additions & 0 deletions website/docs/api/docusaurus.config.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down

0 comments on commit 59fac0b

Please sign in to comment.