Need private packages and team management tools?Check out npm Teams »

remark-mdx-remove-imports

1.5.7 • Public • Published

remark-mdx-remove-imports

Build Status lerna Join the community on Spectrum

Remove import nodes from the MDXAST. This is useful for scenarios where the imports aren’t needed like an MDX playground.

Installation

npm:

npm install --save remark-mdx-remove-imports

Usage

Say we have the following MDX file, example.mdx:

import { Donut } from 'rebass'
 
import OtherThing from 'other-place'
 
export default props => <div {...props} />
 
Hello, world!
 
This is a paragraph

And our script, example.js, looks as follows:

const vfile = require('to-vfile')
const remark = require('remark')
const mdx = require('remark-mdx')
const removeImports = require('remark-mdx-remove-imports')
 
remark()
  .use(mdx)
  .use(removeImports)
  .process(vfile.readSync('example.md'), function(err, file) {
    if (err) throw err
    console.log(String(file))
  })

Now, running node example yields:

export default props => <div {...props} />
 
Hello, world!
 
This is a paragraph

Contribute

See the Support and Contributing guidelines on the MDX website for ways to (get) help.

This project has a Code of Conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.

License

MIT © John Otander

Install

npm i remark-mdx-remove-imports

DownloadsWeekly Downloads

239

Version

1.5.7

License

MIT

Unpacked Size

4.32 kB

Total Files

4

Homepage

mdxjs.com

Last publish

Collaborators

  • avatar
  • avatar
  • avatar
  • avatar