@pondorasti/remark-img-links

Prefix relative image paths with an absolute URL.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@pondorasti/remark-img-links
641.0.83 years ago3 years agoMinified + gzip package size for @pondorasti/remark-img-links in KB

Readme

Lint and Test NPM NPM Downloads Size
remark-img-links
remark plugin to prefix relative image paths with an absolute URL.

Installation

npm install @pondorasti/remark-img-links

Usage

Source

const html = require("remark-html")
const remark = require("remark")
const imgLinks = require("@pondorasti/remark-img-links")

remark()
  .use(imgLinks, { absolutePath: "https://cdn.domain.com/" })
  .use(html)
  .process("![Screenshot](images/screenshot.png)", (err, file) => {
    if (err) throw err
    console.log(String(file))
  })

Yields

<p><img src="https://cdn.domain.com/images/screenshot.png" alt="Screenshot"></p>

API

remark.use(imgLinks[, options])

  • options.absolutePath (required) - the absolute path that will be prepended to the begging of image links.

Contributions

If you are interested in contributing to this project, please open an issue with a description of what you would like to add.

License

MIT © Alexandru Turcanu