remark-import-code
### Install
Last updated a year ago by pomber .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install remark-import-code 
SYNC missed versions from official npm registry.

remark-import-code

Install

$ npm install remark-import-code

Use

The idea is to transform md/mdx like this:

```js file=./hello-world.js
```

Into:

```js
function helloWorld() {
  return "hello world";
}
```

But this plugin gets you half way there. You need to use the remark-import-code/loader somewhere (maybe in webpack). I use it like this with gatsby:

import { MDXRenderer } from "gatsby-plugin-mdx";
import replaceCode from "remark-import-code/loader";

// ...
<MDXRenderer>{replaceCode(post.body)}</MDXRenderer>;
// ...

This shouldn't be necessary, but I don't know how to get the file path when the plugin runs. Ideally it should work like remark-embed-images.

Current Tags

  • 0.0.2                                ...           latest (a year ago)

2 Versions

  • 0.0.2                                ...           a year ago
  • 0.0.1                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 1
Dependencies (2)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |