metalsmith-link-checker
TypeScript icon, indicating that this package has built-in type declarations

2.1.3 • Public • Published

metalsmith-link-checker

npm: version npm: downloads

Snyk: vulnerabilities codecov: coverage license

A Metalsmith plugin to check for local and remote broken links.

This plugin checks a number of different link types and protocols:

  • http: and https: remote links (with backoff and retry)
  • Local links (both relative and absolute)
  • facetime: and facetime-audio: phone numbers and email addresses
  • mailto: email links
  • sms: phone numbers
  • tel: phone numbers

If there are any broken or invalid links found, all of them will be printed to console and the Metalsmith build will stop.

Installation

npm install --save metalsmith-link-checker

JavaScript Usage

This plugin will cause a build error if any links are broken:

import Metalsmith from 'metalsmith';
import linkChecker from 'metalsmith-link-checker';

Metalsmith(__dirname)
    .use(linkChecker({
        // options here
    }))
    .build((err) => {
        if (err) {
            throw err;
        }
    });

Options

html.pattern (optional)

Type: string Default: "**/*.html"

A micromatch glob pattern to find HTML files.

html.tags (optional)

Type: object Default:

{
  "a": "href",
  "img": ["src", "data-src"],
  "link": "href",
  "script": "src"
}

An object of what tags and attributes to look for links in.

ignore (optional)

Type: string[] Default: []

An array of regular expressions of links to be ignored.

timeout (optional)

Type: number Default: 10000

The network timeout when checking external links, in milliseconds.

attempts (optional)

Type: number Default: 3

The number of times to attempt checking external links.

userAgent (optional)

Type: string Default: the top result from top-user-agents

The user agent to use when making network requests.

parallelism (optional)

Type: number Default: 100

The maximum number of async operations at a time.

Changelog

Changelog

Package Sidebar

Install

npm i metalsmith-link-checker

Weekly Downloads

6

Version

2.1.3

License

GPL-3.0-or-later

Unpacked Size

63.2 kB

Total Files

6

Last publish

Collaborators

  • emmercm