MCPcopy Create free account
hub / github.com/contentlayerdev/contentlayer / mdxToHtml

Function mdxToHtml

examples/node-script-mdx/contentlayer.config.ts:6–13  ·  view source on GitHub ↗
(mdxSource: string)

Source from the content-addressed store, hash-verified

4import { getMDXComponent } from 'mdx-bundler/client/index.js'
5
6const mdxToHtml = async (mdxSource: string) => {
7 const { code } = await bundleMDX({ source: mdxSource })
8 const MDXLayout = getMDXComponent(code)
9 // TODO add your own components here
10 const element = MDXLayout({ components: {} })!
11 const html = ReactDOMServer.renderToString(element)
12 return html
13}
14
15const Post = defineDocumentType(() => ({
16 name: 'Post',

Callers 1

Calls 2

bundleMDXFunction · 0.85
getMDXComponentFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…