Processes HTML pages using Cheerio and modifies external facing link attributes.
$ npm install metalsmith-external-links --save-dev
Pass with options to Metalsmith#use
:
var extlinks = require('metalsmith-external-links');
metalsmith.use(extlinks({
domain: 'google.com'
whitelist: [],
rel: 'external',
target: '_blank',
extClass: 'external'
}));
There are a couple options available to make external links more useful.
A string containing the domain name (name.ca) without protocol and www
. Example: npmjs.com
.
A glob string or list of glob strings used to match urls.
String used to change element rel
attribute, leaves rel
unchanged if set to undefined
.
String used to change element target
attribute, leaves target
unchanged if set to undefined
.
Class added to element when it's external, will leave class
unchanged if set to undefined
.
MIT