A Metalsmith plugin to check for local and remote broken links.
This plugin checks a number of different link types and protocols:
http:andhttps:remote links (with backoff and retry)- Local links (both relative and absolute)
facetime:andfacetime-audio:phone numbers and email addressesmailto:email linkssms:phone numberstel: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.
npm install --save metalsmith-link-checkerThis plugin will cause a build error if any links are broken:
const Metalsmith = require('metalsmith');
const linkChecker = require('metalsmith-link-checker');
Metalsmith(__dirname)
.use(linkChecker({
// options here
}))
.build((err) => {
if (err) {
throw err;
}
});Type: string Default: **/*.html
A micromatch glob pattern to find HTML files.
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.
Type: string[] Default: []
An array of regular expressions of links to be ignored.
Type: number Default: 10000
The network timeout when checking external links, in milliseconds.
Type: number Default: 3
The number of times to attempt checking external links.
Type: string Default: the top result from top-user-agents
The user agent to use when making network requests.
Type: number Default: 100
The maximum number of async operations at a time.