Skip to main content

MDX

input.mdx
export const Thing = () => <>World</>;

# Hello <Thing />
output-outline.jsx
/* @jsxRuntime automatic @jsxImportSource react */

export const Thing = () => <>World</>;

export default function MDXContent() {
return (
<h1>
Hello <Thing />
</h1>
);
}
  • 默认 export MDXContent
    • props
      • components: Record<string,ComponentType> | ()=>Record<string,ComponentType>
  • export default function Layout - 同 components.wrapper
  • <MDXProvider components={components}></MDXProvider>
    • 上下文配置好组件

Notes

Version

MDX v3

  • 支持 await
  • 支持 ES2024 语法 - 更新 Acorn
  • Adjacent block JSX and expressions in MDX
<style>{`

h1 {
color: blue;
}

`}</style>

MDX v2