@sardine/eleventy-plugin-external-links

An eleventy plugin to enforce safe external links

Usage no npm install needed!

<script type="module">
  import sardineEleventyPluginExternalLinks from 'https://cdn.skypack.dev/@sardine/eleventy-plugin-external-links';
</script>

README

@sardine/eleventy-plugin-external-links

An 11ty plugin to protect you external links.

Features

Adds target="_blank" rel="noreferrer" to all external links to make them safer.

Original Anchor tags:

<html>
  <body>
    <a href="https://www.external.com">Hello to the outside!</a>
    <a href="/internal/link/">Hello to me!</a>
  </body>
</html>

Generated Anchor tags:

<html>
  <body>
    <a href="https://www.external.com" target="_blank" rel="noreferrer">Hello to the outside!</a>
    <a href="/internal/link/">Hello to me!</a>
  </body>
</html>

Requirements

Installation

npm install --save-dev @sardine/eleventy-plugin-external-links

How to use it

const safeLinks = require('@sardine/eleventy-plugin-external-links');
module.exports = function (eleventyConfig) {
  eleventyConfig.addPlugin(safeLinks);
};

License

MIT