Next.js: React Component to HTML #1361
-
I want to parse a React component to HTML with MDX.
and it outputs
I started with a plugin where I define the <template component>
<Button />
</template> I tried to use snippet = snippet.replace(
/<template\s+(?:class="([^"]*)"\s+)?component(?:\s+class="([^"]*)")?>(.*?)<\/template>/is,
(m, class1, class2, content) => {
return ReactDOMServer.renderToString(content)
}
) Does anyone have an idea how to make this work? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
@alexanderbluhm this seems very much like an XY Problem. |
Beta Was this translation helpful? Give feedback.
@alexanderbluhm this seems very much like an XY Problem.
There is a guide on creating pages in MDX on Next in the documentation site https://mdxjs.com/getting-started/next
Is there a particular reason you want to go another route? If so what is the end problem you are trying to solve? And why is bypassing the toolchain a constraint?