@pondorasti/remark-img-links
v1.0.8
Published
Prefix relative image paths with an absolute URL.
Downloads
4,860
Maintainers
Readme
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.