@abhisheknairofficial/use-markdown 中文文档教程
useMarkDown
useMarkDown 是一个简单的 React Hook,可让您将 MD 文件内容显示为 React 组件。 这是使用 React Markdown 构建的,为了方便,我刚刚单独制作了一个。
Installation
安装非常简单。 使用 npm 或纱线。
npm i @abhisheknairofficial/use-markdown
或
yarn add @abhisheknairofficial/use-markdown
Usage
- Import into your file as follows:
import useMarkDown from '@abhisheknairofficial/use-markdown'
- Import your MD file similarly
import MARKDOWN_FILE from '../foo/bar/index.md'
- Use it in your component in either of the following ways:
const MyReactComponent = (props) => {
const myMarkdownData = useMarkDown(MARKDOWN_FILE)
return <>{myMarkdownData}</>
}
或
const MyReactComponent = (props) => {
return <>{useMarkDown(MARKDOWN_FILE)}</>
}
useMarkDown
useMarkDown is a simple React Hook that lets you show your MD file contents as a React component. This is built using React Markdown, and I have just made a separate one for convenience.
Installation
Installation is straight-forward. Use either npm or yarn.
npm i @abhisheknairofficial/use-markdown
or
yarn add @abhisheknairofficial/use-markdown
Usage
- Import into your file as follows:
import useMarkDown from '@abhisheknairofficial/use-markdown'
- Import your MD file similarly
import MARKDOWN_FILE from '../foo/bar/index.md'
- Use it in your component in either of the following ways:
const MyReactComponent = (props) => {
const myMarkdownData = useMarkDown(MARKDOWN_FILE)
return <>{myMarkdownData}</>
}
or
const MyReactComponent = (props) => {
return <>{useMarkDown(MARKDOWN_FILE)}</>
}