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
This commit is contained in:
Marcus Blättermann 2022-11-25 03:24:04 +01:00
parent 799013c4cf
commit 049279657a
No known key found for this signature in database
GPG Key ID: A1E1F04008AC450D
2 changed files with 13 additions and 1 deletions

View File

@ -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

View File

@ -37,7 +37,6 @@ export const remarkComponents = {
p: P,
pre: Pre,
code: Code,
inlineCode: InlineCode,
del: TypeAnnotation,
table: Table,
img: Image,