@mdx-js/tag
Version:
A fully-featured Markdown/MDX React component for ambitious projects
77 lines (46 loc) • 1.69 kB
Markdown
[![Build Status][build-badge]][build]
[![lerna][lerna-badge]][lerna]
[![Join the community on Spectrum][spectrum-badge]][spectrum]
Map components to HTML elements based on the Markdown syntax.
Useful with [MDX][].
[][]:
```sh
npm i -S @mdx-js/tag
```
```jsx
import React from 'react'
import {renderToString} from 'react-dom/server'
import {MDXTag} from '@mdx/tag'
const H1 = props => <h1 style={{color: 'tomato'}} {...props} />
console.log(renderToString(<MDXTag name="h1" children="Hello, world!" />))
console.log(renderToString(<MDXTag name="h1" components={{h1: H1}} children="Hello, world!" />))
```
Yields:
```html
<h1>Hello, world!</h1>
<h1 style="color:tomato">Hello, world!</h1>
```
See [`contributing.md` in `mdx-js/mdx`][contributing] for ways to get started.
This organisation has a [Code of Conduct][coc].
By interacting with this repository, organisation, or community you agree to
abide by its terms.
[][] © [Compositor][] and [ZEIT][]
<!-- Definitions -->
[]: https://travis-ci.org/mdx-js/mdx
[]: https://travis-ci.org/mdx-js/mdx.svg?branch=master
[]: https://lernajs.io/
[]: https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg
[]: https://spectrum.chat/mdx
[]: https://withspectrum.github.io/badge/badge.svg
[]: https://github.com/mdx-js/mdx/blob/master/contributing.md
[]: https://github.com/mdx-js/mdx/blob/master/code-of-conduct.md
[]: license
[]: https://compositor.io
[]: https://zeit.co
[]: https://github.com/mdx-js/mdx
[]: https://docs.npmjs.com/cli/install