This is a Docusaurus theme to add support for MDX v2 until it is officially supported.
- Upgrade Docusaurus to version
2.0.0-beta.18
or later - Upgrade your
@mdx-js/react
dependency to version^2.0.0
- Install
docusaurus-theme-mdx-v2
npm install docusaurus-theme-mdx-v2
- Add
mdx-v2
theme to yourdocusaurus.config.js
// ...
const config = {
//...
presets: [...],
themes: ["mdx-v2"],
themeConfig: ...
//...
}
// ...
- Migrate your .md and .mdx files to MDX v2 if you need. The most common breaking changes are:
- You cannot use comments like this
<!--comment-->
anymore. Now you should use something like{/* prettier-ignore */}
- You need to escape
{
in your prose like this\{
- If you are using components that aren't imported or part of the
MDXComponents
, MDX v2 will throw an error (v1 only showed a warning)
Instead of using the markdown syntax for admonitions, you should use the
<Admonition />
component.
Instead of this:
:::note Your Title
Some **content** with _markdown_ `syntax`.
:::
Use this:
import Admonition from '@theme/Admonition'
<Admonition type="note" title="Your Title">
Some **content** with _markdown_ `syntax`.
</Admonition>
MIT