JSPM

posthtml-external-link

0.1.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 68
  • Score
    100M100P100Q71234F
  • License MIT

Add 'rel="external noopener nofollow"' and 'target="_blank"' to all external links [PostHTML Plugin]

Package Exports

  • posthtml-external-link

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (posthtml-external-link) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

posthtml-external-link

Version License Build using TypeScript

A PostHTML plugin to add rel="external noopener nofollow" and "target=_blank" to all external links automatically, for privacy and SEO. Read more.

Installations

$ npm i -D posthtml-external-link
$ yarn add posthtml-external-link -D # If you prefer yarn

Usage

Since posthtml-external-link is a PostHTML plugin, just add posthtml-external-link to PostHTML plugins array.

const posthtml = require('posthtml');
const { posthtmlExternalLink } = require('posthtml-external-link');

posthtml([
  // Other PostHTML plugins
  postHtmlExternalLink({
    // Here goes options
  }),
  // Other PostHTML plugins
]).process(source/* input html */)
  .then(result => console.log(result.html))

Options

postHtmlExternalLink({
  exclude: ['exclude1.com', 'exclude2.com'],
  noreferrer: false
}),

exclude (string | string[])

Exclude hostname. Specify subdomain when applicable.

exclude1.com does not apply to www.exclude1.com nor en.exclude1.com.

noreferrer (boolean)

Whether to add noreferrer to external links' rel attribute.

Maintainer

posthtml-external-link © Sukka, Released under the MIT License.
Authored and maintained by Sukka with help from contributors (list).

Personal Website · Blog · GitHub @SukkaW · Telegram Channel @SukkaChannel · Twitter @isukkaw · Keybase @sukka