https://github.com/remcohaszing/recma-mdx-is-mdx-component
A recma plugin to define the isMdxComponent property on MDX components.
https://github.com/remcohaszing/recma-mdx-is-mdx-component
is-mdx-component ismdxcomponent mdx recma recma-plugin
Last synced: about 2 months ago
JSON representation
A recma plugin to define the isMdxComponent property on MDX components.
- Host: GitHub
- URL: https://github.com/remcohaszing/recma-mdx-is-mdx-component
- Owner: remcohaszing
- License: mit
- Created: 2023-08-31T09:11:56.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-22T20:44:18.000Z (3 months ago)
- Last Synced: 2025-03-29T08:43:31.186Z (3 months ago)
- Topics: is-mdx-component, ismdxcomponent, mdx, recma, recma-plugin
- Language: JavaScript
- Homepage:
- Size: 739 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# recma-mdx-is-mdx-component
[](https://github.com/remcohaszing/recma-mdx-is-mdx-component/actions/workflows/ci.yaml)
[](https://www.npmjs.com/package/recma-mdx-is-mdx-component)
[](https://www.npmjs.com/package/recma-mdx-is-mdx-component)
[](https://codecov.io/gh/remcohaszing/recma-mdx-is-mdx-component)A recma plugin to define the `isMDXComponent` property on MDX components.
## Table of Contents
- [Installation](#installation)
- [Usage](#usage)
- [API](#api)
- [Compatibility](#compatibility)
- [License](#license)## Installation
```sh
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:
```mdx
Some MDX content
```The following script:
```js
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:
```jsx
MDXContent.isMDXComponent = true
export default function MDXContent() {
returnSome MDX content
}
```## API
The default export is a recma plugin. It takes no options.
## Compatibility
This project is compatible with Node.js 20 or greater.
## License
[MIT](LICENSE.md) © [Remco Haszing](https://github.com/remcohaszing)