# gatsby-remark-relative-images-v2

> Convert image src(s) in markdown to be relative to their node's parent directory. This will help gatsby-remark-images match images outside the node folder. For example, use with NetlifyCMS.

Latest version **0.1.5** (published 2018-09-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install gatsby-remark-relative-images-v2
pnpm add gatsby-remark-relative-images-v2
yarn add gatsby-remark-relative-images-v2
bun add gatsby-remark-relative-images-v2
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2018-09-06 |
| First published | 2018-09-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 11.9 KB |
| Known vulnerabilities | 0 (+8 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Zach Schnackel |
| Maintainers | zachschnackel |
| Keywords | gatsby, gatsby-plugin, image, markdown, relative, netlifycms, remark, responsive images |

## Links

- npm: https://www.npmjs.com/package/gatsby-remark-relative-images-v2
- Repository: https://github.com/zslabs/gatsby-remark-relative-images-v2
- Homepage: https://github.com/zslabs/gatsby-remark-relative-images-v2#readme
- Issues: https://github.com/zslabs/gatsby-remark-relative-images-v2/issues
- npm.io page: https://npm.io/package/gatsby-remark-relative-images-v2

## Dependencies (7)

- [slash](https://npm.io/package/slash.md) 2.0.0
- [lodash](https://npm.io/package/lodash.md) 4.17.5
- [cheerio](https://npm.io/package/cheerio.md) 1.0.0-rc.2
- [deep-map](https://npm.io/package/deep-map.md) 1.5.0
- [babel-polyfill](https://npm.io/package/babel-polyfill.md) ^6.26.0
- [is-relative-url](https://npm.io/package/is-relative-url.md) 2.0.0
- [unist-util-select](https://npm.io/package/unist-util-select.md) 1.5.0

## Alternatives

- [@mdxeditor/editor](https://npm.io/package/@mdxeditor/editor.md) — 962.4K weekly downloads
- [mmdb-lib](https://npm.io/package/mmdb-lib.md) — 680.9K weekly downloads
- [playcanvas](https://npm.io/package/playcanvas.md) — 36.2K weekly downloads
- [@glw907/cairn-cms](https://npm.io/package/@glw907/cairn-cms.md) — 967 weekly downloads
- [markdown-to-confluence](https://npm.io/package/markdown-to-confluence.md) — 103 weekly downloads

## Recent versions

- 0.1.5 (latest) — 2018-09-06
- 0.1.4 — 2018-09-06
- 0.1.3 — 2018-09-06
- 0.1.2 — 2018-09-06

## README

# gatsby-remark-relative-images-v2

Convert image src(s) in markdown to be relative to their node's parent directory. This will help [gatsby-remark-images](https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-remark-images) match images outside the node folder. For example, use with NetlifyCMS.

NOTE: This was built for use with NetlifyCMS and should be considered a temporary solution until relative paths are supported. If it works for other use cases than great!

## Install

`npm install --save gatsby-remark-relative-images-v2`

## How to use

```javascript
// gatsby-config.js
plugins: [
  // Add static assets before markdown files
  {
    resolve: 'gatsby-source-filesystem',
    options: {
      path: `${__dirname}/static/uploads`,
      name: 'uploads',
    },
  },
  {
    resolve: 'gatsby-source-filesystem',
    options: {
      path: `${__dirname}/src/pages`,
      name: 'pages',
    },
  },
  {
    resolve: `gatsby-transformer-remark`,
    options: {
      plugins: [
        // gatsby-remark-relative-images-v2 must
        // go before gatsby-remark-images
        {
          resolve: `gatsby-remark-relative-images-v2`,
        },
        {
          resolve: `gatsby-remark-images`,
          options: {
            // It's important to specify the maxWidth (in pixels) of
            // the content container as this plugin uses this as the
            // base for generating different widths of each image.
            maxWidth: 590,
          },
        },
      ],
    },
  },
];
```

### To convert frontmatter images

Use the exported function `fmImagesToRelative` in your `gatsby-node.js`. This takes every node returned by your gatsby-source plugins and converts any absolute paths in markdown frontmatter data into relative paths if a matching file is found.

```js
// gatsby-node.js
const { fmImagesToRelative } = require('gatsby-remark-relative-images-v2');

exports.onCreateNode = ({ node }) => {
  fmImagesToRelative(node);
};
```

---
_Source: https://npm.io/package/gatsby-remark-relative-images-v2 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
