Gatsby中怎么使用MDX?

一、MDX 是啥?MDX 是一种文档格式,可以在 Markdown 文档中无缝地插入 JSX 代码。import {Chart} from './snowfall.js'export const year = 2018# Last year’s snowfallIn {year}, the snowfall was above average.It was followed by a warm spring which causedflood conditions in many of t
摘要由CSDN通过智能技术生成
一、MDX 是啥?

MDX 是一种文档格式,可以在 Markdown 文档中无缝地插入 JSX 代码。

import {Chart} from './snowfall.js'
export const year = 2018

# 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" />

二、Gatsby 中使用 MDX
1、安装插件

把 markdown 文件,转为gatsby 数据层节点。

# 安装插件及其依赖库
npm install gatsby-source-filesystem gatsby-plugin-mdx @mdx-js/mdx @mdx-js/react
# 或
yarn add gatsby-source-filesystem gatsby-plugin-mdx @mdx-js/mdx @mdx-js/react
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值