Gatsby
要将 MDX 用于 Gatsby,需要安装 gatsby-plugin-mdx 插件。
首先,创建一个新的 Gatsby 2.0 或更高版本的站点,然后安装 gatsby-plugin-mdx
插件。
gatsby new gatsby-sitecd gatsby-siteyarn add gatsby-plugin-mdx @mdx-js/mdx@latest @mdx-js/react@latest
再添加 gatsby-plugin-mdx
到 gatsby-config.js
配置文件的 plugins
配置段中。
module.exports = {siteMetadata: {title: `My Ambitious Project`},plugins: [`gatsby-plugin-mdx`]}
最后,在src/pages
目录下添加一个 .mdx
文件。
看一看是不是 “起作用了”。
# My first MDX Pagesome awesome content
有关使用 Gatsby 以编程方式创建页面的文档,请 参阅 Gatsby MDX 文档。
Edit this page on GitHub