在 markdown 中添加组件,如:示例

如何做到?

使用 mdx

代码:

import {Chart} from './snowfall.js'
export const year = 2023
 
# Last year’s snowfall
 
In {year}, the snowfall was above average. It was followed by a warm spring which caused flood conditions in many of the nearby rivers.
 
<Chart year={year} color="#fcb32c" />

渲染: