Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/posthtml/posthtml-external-link
Add "rel='external noopenner nofollow'" and "target=_blank" to all external links
https://github.com/posthtml/posthtml-external-link
posthtml posthtml-plugin seo
Last synced: 12 days ago
JSON representation
Add "rel='external noopenner nofollow'" and "target=_blank" to all external links
- Host: GitHub
- URL: https://github.com/posthtml/posthtml-external-link
- Owner: posthtml
- License: mit
- Created: 2020-11-18T14:43:43.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-06-04T19:44:35.000Z (over 3 years ago)
- Last Synced: 2024-10-29T21:06:05.014Z (14 days ago)
- Topics: posthtml, posthtml-plugin, seo
- Language: TypeScript
- Homepage:
- Size: 135 KB
- Stars: 11
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# posthtml-external-link
[![Version](https://img.shields.io/npm/v/posthtml-external-link.svg?style=flat-square)](https://www.npmjs.com/package/posthtml-external-link)
[![License](https://img.shields.io/npm/l/posthtml-external-link.svg?style=flat-square)](./LICENSE)
[![Build using TypeScript](https://img.shields.io/badge/definitions-TypeScript-blue.svg?style=flat-square)](https://www.typescriptlang.org/)A [PostHTML](https://posthtml.org) plugin to add `rel="external noopener nofollow"` and `"target=_blank"` to all external links automatically, for privacy and SEO. [Read more](https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types).
## Installations
```bash
$ npm i -D posthtml-external-link
$ yarn add posthtml-external-link -D # If you prefer yarn
```## Usage
Since `posthtml-external-link` is a [PostHTML](https://posthtml.org) plugin, just add `posthtml-external-link` to PostHTML plugins array.
```js
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
```js
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](https://github.com/SukkaW), Released under the [MIT](./LICENSE) License.
Authored and maintained by Sukka with help from contributors ([list](https://github.com/SukkaW/posthtml-external-link/contributors)).> [Personal Website](https://skk.moe) · [Blog](https://blog.skk.moe) · GitHub [@SukkaW](https://github.com/SukkaW) · Telegram Channel [@SukkaChannel](https://t.me/SukkaChannel) · Twitter [@isukkaw](https://twitter.com/isukkaw) · Keybase [@sukka](https://keybase.io/sukka)