JSPM

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

Automatically adds the target and rel attributes to external links

Package Exports

  • remark-external-links

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 (remark-external-links) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

remark-external-links Build Status Coverage Status Chat

Add target and rel attributes to external links with remark.

Installation

npm:

npm install remark-external-links

Usage

Say we have the following file, example.js:

var html = require('remark-html')
var remark = require('remark')
var externalLinks = require('remark-external-links')

remark()
  .use(externalLinks, {target: false, rel: ['nofollow']})
  .use(html)
  .process('[remark](https://github.com/remarkjs/remark)', function(err, file) {
    if (err) throw err
    console.log(String(file))
  })

Now, running node example yields:

<p><a href="https://github.com/remarkjs/remark" rel="nofollow">remark</a></p>

API

Add target and rel attributes to external links.

options.target

How to display referenced documents (string?: _self, _blank, _parent, or _top, default: _blank). Pass false to not set targets on links.

options.rel

Link types to hint about the referenced documents (Array.<string> or string, default: ['nofollow', 'noopener', 'noreferrer']). Pass false to not set rels on links.

When using a target, add noopener and noreferrer to avoid exploitation of the window.opener API.

Contribute

See contributing.md in remarkjs/remark for ways to get started.

This organisation has a Code of Conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.

License

MIT © Cédric Delpoux