From 54adccb3087aa6474398e031adea79e23318380c Mon Sep 17 00:00:00 2001 From: sebastienlorber Date: Wed, 7 Dec 2022 17:18:01 +0100 Subject: [PATCH 1/3] document config.markdown + better mdx-loader retrocompat --- packages/docusaurus-mdx-loader/README.md | 4 ++++ packages/docusaurus-mdx-loader/src/loader.ts | 2 +- website/docs/api/docusaurus.config.js.md | 24 ++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/packages/docusaurus-mdx-loader/README.md b/packages/docusaurus-mdx-loader/README.md index 92a22ca6d817..a2adfbeb4b9b 100644 --- a/packages/docusaurus-mdx-loader/README.md +++ b/packages/docusaurus-mdx-loader/README.md @@ -44,3 +44,7 @@ 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`) diff --git a/packages/docusaurus-mdx-loader/src/loader.ts b/packages/docusaurus-mdx-loader/src/loader.ts index 12ac0e192fda..fee2920a2e63 100644 --- a/packages/docusaurus-mdx-loader/src/loader.ts +++ b/packages/docusaurus-mdx-loader/src/loader.ts @@ -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, { diff --git a/website/docs/api/docusaurus.config.js.md b/website/docs/api/docusaurus.config.js.md index 2b42d82b6fb5..87a4525e0a66 100644 --- a/website/docs/api/docusaurus.config.js.md +++ b/website/docs/api/docusaurus.config.js.md @@ -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`. From 97833e403a65e5fda673a3f93da7a33327797b5d Mon Sep 17 00:00:00 2001 From: sebastienlorber Date: Wed, 7 Dec 2022 17:18:25 +0100 Subject: [PATCH 2/3] document config.markdown + better mdx-loader retrocompat --- packages/docusaurus-mdx-loader/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/docusaurus-mdx-loader/README.md b/packages/docusaurus-mdx-loader/README.md index a2adfbeb4b9b..1f9a87799948 100644 --- a/packages/docusaurus-mdx-loader/README.md +++ b/packages/docusaurus-mdx-loader/README.md @@ -47,4 +47,4 @@ A function to provide the metadataPath depending on current loaded MDX path that ### `markdownConfig` -The global Docusaurus Markdown config (`config.markdown`) +The global Docusaurus Markdown config (`config.markdown`). From d5a0b790d16e3fdcc397741a69c0d7707a2ac1a5 Mon Sep 17 00:00:00 2001 From: sebastienlorber Date: Wed, 7 Dec 2022 17:21:03 +0100 Subject: [PATCH 3/3] document config.markdown + better mdx-loader retrocompat --- packages/docusaurus-mdx-loader/README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/docusaurus-mdx-loader/README.md b/packages/docusaurus-mdx-loader/README.md index 1f9a87799948..b3a60699a6b5 100644 --- a/packages/docusaurus-mdx-loader/README.md +++ b/packages/docusaurus-mdx-loader/README.md @@ -47,4 +47,13 @@ A function to provide the metadataPath depending on current loaded MDX path that ### `markdownConfig` -The global Docusaurus Markdown config (`config.markdown`). +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, + }, +}; +```