recma-mdx-is-mdx-component
TypeScript icon, indicating that this package has built-in type declarations

1.1.3 • Public • Published

recma-mdx-is-mdx-component

github actions npm version npm downloads codecov

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.

License

MIT © Remco Haszing

Package Sidebar

Install

npm i recma-mdx-is-mdx-component

Weekly Downloads

17

Version

1.1.3

License

MIT

Unpacked Size

5.67 kB

Total Files

6

Last publish

Collaborators

  • remcohaszing