1.0.10 • Published 3 years ago

posthtml-link-noreferrer v1.0.10

Weekly downloads
62
License
MIT
Repository
github
Last release
3 years ago

posthtml-link-noreferrer

NPM npm Deps DevDeps Build

This plugin add rel="noopener" and rel="noreferrer" to all links that contain the attribute target="_blank".

Read more about problem in google blog.

⭐️ Star me on GitHub — it helps!

Before:

<a href="/" target="_blank">External link</a>
<a href="/" target="_blank" rel="nofollow">External link</a>
<a href="/" target="_self">Home</a>

After:

<a href="/" target="_blank" rel="noopener noreferrer">External link</a>
<a href="/" target="_blank" rel="nofollow">External link</a>
<a href="/" target="_self">Home</a>

Demo

DEMO

Install

npm i posthtml-link-noreferrer --save-dev

Usage

Gulp

npm i gulp-posthtml posthtml-link-noreferrer --save-dev
const gulp = require('gulp');
const postHTML = require('gulp-posthtml');
const postHTMLNoRef = require('posthtml-link-noreferrer');

const config = () => ({
  plugins: [
    postHTMLNoRef({
      attr: ['noopener', 'noreferrer']
    }),
  ],
});

gulp.task('posthtml', () => gulp.src('./build/*.html')
  .pipe(postHTML(config))
  .pipe(gulp.dest('./build')));

Webpack

npm i html-loader posthtml-loader posthtml-link-noreferrer  --save-dev
module: {
  rules: [
    {
      test: /\.html$/,
      use: [
        'html-loader',
        {
          loader: 'posthtml-loader',
          options: {
            plugins: [
              require('posthtml-link-noreferrer')({
                attr: ['noopener', 'noreferrer']
              })
            ]
          }
        }
      ]
    }
  ]
}

Options

OptionTypedescriptionPossible subsetsDefault value
attrarrayDescribes rel attributes.'noopener', 'noreferrer', 'nofollow''noopener', 'noreferrer'

Contributing

See PostHTML Guidelines and contribution guide.

License MIT

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago