Skip to content

Instantly share code, notes, and snippets.

@pomber
Last active Oct 6, 2021
Embed
What would you like to do?
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