Automatically add target et rel attributes on external links.
Install
npm:
npm install remark-external-links --save
yarn:
yarn add remark-external-links
Example
remark-external-links is designed to work with
remark-html.
It add target and rel attributes on external links:
var externalLinks = require("remark-external-links")
var html = require("remark-html")
var remark = require("remark")
import externalLinks from "remark-external-links"
import html from "remark-html"
import remark from "remark"
remark()
.use(externalLinks)
.use(html)
.process("[remark](https://github.com/gnab/remark)")
Note that this module must be included before remark-html.
API
options
target
Type: string
Default: _blank
Specifies where to display the linked URL.
The value should be on of : _self
, _blank
, _parent
, _top
rel
Type: string
Default: nofollow noopener noreferrer
Specifies the relationship of the target object to the link object.
The value is a space-separated list of link types.
When using target, consider adding rel="noopener noreferrer" to avoid exploitation of the window.opener API.
Changelog
See changelog
Contributing
Pull requests are welcome. If you add functionality, then please add unit tests
to cover it.
Development
Clean lib
folder
npm run clean
Build lib
folder
npm run build
Lint src
folder
npm run lint
Test src
folder
npm run test
License
MIT