Closed jer-k closed 6 months ago
This seems to be caused by the way that MDX renders. https://mdxjs.com/table-of-components/ we can see
that single backticks renders <code>
as well as triple backtick doing a <pre>
and a <code>
. When I console log what is being the props are from here https://github.com/code-hike/bright/blob/main/lib/src/index.tsx#L200 I get
what is c.props {
className: 'language-js',
children: 'let hello = "hello brightness"\nconsole.log(hello, "my old friend")\n'
}
I added a change to make the code look like
const subProps = React.Children.toArray(children as any).map((c: any) => {
let codeProps = c.props?.children?.props
if (!codeProps) {
codeProps = c.props;
}
return {
code: trimTrailingNewline(codeProps.children),
...getLanguageAndTitle(codeProps.className),
}
})
return {
subProps,
}
In mdx-components I have
export function useMDXComponents(components: MDXComponents) {
return { ...components, pre: Code, code: ({children}) => <code>{children}</code> }
}
The demo page has
The result is
Not sure if this change would break other things?
Thanks for reporting and researching. Should be fixed on v0.8.5.
@pomber I use v0.8.5 and still experience same issue.
Following the instructions from https://bright.codehike.org/
I set this up and it is working great. I have
.mdx
files where I'll doand it renders the HTML as
<p>here is some text<code>some_file_name.txt</code> some text</p>
. I was trying to figure out how to change the styling of the<code>
tags. I followed the Next Mdx guide and did something simple likeThis breaks when
bright
has been imported. Whenbright
is no imported, it works as expected (albeit looking quite weird).Some related issues seem to be
code:
The error I see
I am using https://github.com/code-hike/bright/releases/tag/bright%400.8.4