Miss any of our Open RFC calls?Watch the recordings here! »

md-tools-plugin-component-react

1.0.1 • Public • Published

md-tools-plugin-component-react

把 Markdown 里的 jsx 代码块转换成 React.Element.

用法

  1. 安装依赖:
npm i -D md-tools-plugin-component-react
  1. 在主题index配置 plugins 中增加md-tools-plugin-component-react.
module.exports = {
  plugins: ["md-tools-plugin-component-react?lang=jsx"]
};
  1. 在Makdown文件中:
...

This is a button:

```jsx
import { Button } from 'antd';
ReactDOM.render(<Button>Click!</Button>, mountNode);
```

...

如上代码可以渲染成:

screenshot

import { Button } from 'antd';
ReactDOM.render(&lt;Button&gt;Click!&lt;/Button&gt;, mountNode);

API

lang: String

default: 'jsx'

代码块标识

babelConfig: Object

default: { presets: [ 'react', ['env', { targets: { browsers: ['last 2 versions', 'Firefox ESR', '> 1%', 'ie >= 8', 'iOS >= 8', 'Android >= 4'], }, }], ], plugins: [ 'transform-class-properties', 'transform-object-rest-spread', ], }

babel 配置

noreact: Boolean

default: false

是否自动引入 ReactReactDOM .

License

MIT

Install

npm i md-tools-plugin-component-react

DownloadsWeekly Downloads

13

Version

1.0.1

License

MIT

Unpacked Size

3.41 kB

Total Files

3

Last publish

Collaborators

  • avatar
  • avatar
  • avatar