https://github.com/pomber/gatsby-remark-import-code
Gatsby remark plugin to import code from a file into code blocks
https://github.com/pomber/gatsby-remark-import-code
code gatsby gatsby-plugin-mdx import markdown mdx remark remark-plugin remarkjs
Last synced: 9 days ago
JSON representation
Gatsby remark plugin to import code from a file into code blocks
- Host: GitHub
- URL: https://github.com/pomber/gatsby-remark-import-code
- Owner: pomber
- License: mit
- Created: 2019-07-19T20:23:57.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-08-21T12:40:51.000Z (over 4 years ago)
- Last Synced: 2025-04-07T01:18:35.546Z (25 days ago)
- Topics: code, gatsby, gatsby-plugin-mdx, import, markdown, mdx, remark, remark-plugin, remarkjs
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 23
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# gatsby-remark-import-code
### Install
```bash
$ npm install gatsby-remark-import-code
```### Use
Use it together with [gatsby-plugin-mdx](https://www.gatsbyjs.org/packages/gatsby-plugin-mdx/). In `gatsby-config.js`:
```js
module.exports = {
plugins: [
{
resolve: `gatsby-plugin-mdx`,
options: {
gatsbyRemarkPlugins: [`gatsby-remark-import-code`]
}
}
]
};
```It transforms md/mdx code blocks from this:
````md
```js file=./hello-world.js
```
````into:
````md
```js
function helloWorld() {
return "hello world";
}
```
````### Related
- [gatsby-remark-embed-snippet](https://www.gatsbyjs.org/packages/gatsby-remark-embed-snippet/)