Markdown
The Markdown
block allows you to import and include plain markdown in your MDX files.
When importing markdown files, it’s important to use the ?raw
suffix on the import path to ensure the content is imported as-is, and isn’t being evaluated
Markdown
Markdown
is configured with the following props
children
类型: string
提供要解析和显示的 Markdown 格式字符串。
options
指定传递给底层 markdown-to-jsx
库 的选项。
为什么不直接导入 Markdown?
From a purely technical standpoint, we could include the imported markdown directly in the MDX file like this
However, there are small syntactical differences between plain markdown and MDX2. MDX2 is more strict and will interpret certain content as JSX expressions. Here’s an example of a perfectly valid markdown file, that would break if it was handled directly by MDX2
Furthermore, MDX2 wraps all strings on newlines in p
tags or similar, meaning that content would render differently between a plain .md
file and an .mdx
file.