From 049279657aeafa4cd93bedc43ef9e37f0783b188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20Bl=C3=A4ttermann?= Date: Fri, 25 Nov 2022 03:24:04 +0100 Subject: [PATCH] Readd `InlineCode` component MDX2 removed the `inlineCode` component > The special component name `inlineCode` was removed, we recommend to use `pre` for the block version of code, and code for both the block and inline versions Source: https://mdxjs.com/migrating/v2/#update-mdx-content --- website/plugins/remarkCodeBlocks.mjs | 13 +++++++++++++ website/src/remark.js | 1 - 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/website/plugins/remarkCodeBlocks.mjs b/website/plugins/remarkCodeBlocks.mjs index f35ee3de7..0d327e2a9 100644 --- a/website/plugins/remarkCodeBlocks.mjs +++ b/website/plugins/remarkCodeBlocks.mjs @@ -66,6 +66,19 @@ function remarkCodeBlocks(userOptions = {}) { node.data.hProperties = Object.assign({}, hProps, attrs) } }) + + visit(tree, 'inlineCode', (node) => { + node.type = 'mdxJsxTextElement' + node.name = 'InlineCode' + node.children = [ + { + type: 'text', + value: node.value, + }, + ] + node.data = { _mdxExplicitJsx: true } + }) + return tree } return transformer diff --git a/website/src/remark.js b/website/src/remark.js index 3d771c7e7..03ca04ad1 100644 --- a/website/src/remark.js +++ b/website/src/remark.js @@ -37,7 +37,6 @@ export const remarkComponents = { p: P, pre: Pre, code: Code, - inlineCode: InlineCode, del: TypeAnnotation, table: Table, img: Image,