When using MdxComponents HTMLPreElement block strips classnames to only include 1 string. #2551
-
Lets say I have this pre block in my .mdx file: ``ts test
const helloWorld = () => console.log("Hello world!");
`` Ignore that there are only 2 backticks, I have just placed them to escape markdown being used in github. And then I decide to use custom MdxComponents when rendering, so the code should go something like this: export const mdxComponents = {
pre: ({ children, ...props }: React.HTMLAttributes<HTMLPreElement>) => {
console.log(children)
return (
... do stuff
);
}, I will be getting this output: {
'$$typeof': Symbol(react.element),
type: [Function: code],
key: null,
ref: null,
props: {
className: 'language-ts',
children: "const helloWorld = () => console.log('Hello world!');\n"
},
_owner: null,
_store: {}
} And there you can see that the word For context I use Next15 with mdx setup correctly and I am directly viewing page.mdx files. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Welcome @konyogony! 👋 |
Beta Was this translation helpful? Give feedback.
Welcome @konyogony! 👋
Correct code meta does not do anything in mdx by default.
The can be configured by plugins, it sounds specifically like you want something along the lines of https://github.com/remcohaszing/rehype-mdx-code-props