Last active
October 6, 2021 17:09
-
-
Save pomber/758a649aa8ef2a2a353a0da9c7d5e951 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { bundleMDX } from "mdx-bundler"; | |
import { getMDXComponent } from "mdx-bundler/client"; | |
import React from "react"; | |
export async function getServerSideProps() { | |
const mdxSource = ` | |
# Hello | |
~~~js | |
console.log(1); | |
~~~`; | |
const mdxBundle = await bundleMDX(mdxSource); | |
return { props: { mdxBundle } }; | |
} | |
export default function Foo({ mdxBundle }) { | |
const Component = getMDXComponent(mdxBundle.code); | |
return <Component />; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment