recma-mdx-is-mdx-component
v1.1.3
Published
A recma plugin to define the isMDXComponent property on MDX components.
Downloads
83
Maintainers
Readme
recma-mdx-is-mdx-component
A recma plugin to define the isMDXComponent
property on MDX components.
Table of Contents
Installation
npm install recma-mdx-is-mdx-component
Usage
This recma plugin assigns true
to the property MDXContent.isMDXComponent
.
For example, given a file named example.mdx
with the following contents:
Some MDX content
The following script:
import { readFile } from 'node:fs/promises'
import { compile } from '@mdx-js/mdx'
import recmaPluginInjectisMDXComponent from 'recma-mdx-is-mdx-component'
const { contents } = await compile(await readFile('example.mdx'), {
jsx: true,
recmaPlugins: [recmaPluginInjectisMDXComponent]
})
console.log(contents)
Roughly yields:
MDXContent.isMDXComponent = true
export default function MDXContent() {
return <p>Some MDX content</p>
}
API
The default export is a recma plugin. It takes no options.
Compatibility
This project is compatible with Node.js 16 or greater.