feat(mdx): add siteConfig.markdown.format to configure the default content parser (MDX / CommonMark) (#9097)

This commit is contained in:
Sébastien Lorber 2023-06-23 18:15:05 +02:00 committed by GitHub
parent be4e67caa9
commit cc6d9696f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 304 additions and 83 deletions

View file

@ -13,24 +13,9 @@ import TabItem from '@theme/TabItem';
import styles from './markdown-features-react.module.css';
```
## Using JSX in Markdown {#using-jsx-in-markdown}
Docusaurus has built-in support for [MDX v2](https://mdxjs.com/), which allows you to write JSX within your Markdown files and render them as React components.
:::info MDX vs. CommonMark
Docusaurus parses both `.md` and `.mdx` files using MDX, but **the syntax is interpreted differently based on the file extension**:
- With the `.md` extension, the parser is compatible with [CommonMark](https://commonmark.org/) and does not allow the usage of JSX.
- With the `.mdx` extension, the parser is stricter than [CommonMark](https://commonmark.org/) and is not 100% compatible with it, but it becomes possible to use JSX.
It is also possible to override the file extension format with front matter: `format: mdx`.
The rest of this page assumes usage of the `mdx` format.
:::
Check out the [MDX docs](https://mdxjs.com/) to see what other fancy stuff you can do with MDX.
Check out the [MDX docs](https://mdxjs.com/) to see what fancy stuff you can do with MDX.
:::tip Debugging MDX