npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

metalsmith-linkcheck

v0.3.4

Published

Metalsmith plugin for checking links

Downloads

26

Readme

metalsmith-linkcheck

This is a plugin for Metalsmith that checks links—both internal and external. (In contrast to metalsmith-broken-link-checker, which only checks internal links.)

Installation

This module is released via npm, install the latest released version with:

npm install --save metalsmith-linkcheck

Usage

If using the CLI for Metalsmith, metalsmith-linkcheck can be used like any other plugin by including it in metalsmith.json:

{
  "plugins": {
    "metalsmith-linkcheck"
  }
}

For Metalsmith's JavaScript API, metalsmith-linkcheck can be used like any other plugin, by attaching it to the function invocation chain on the metalscript object:

var linkcheck = require('metalsmith-linkcheck');
require('metalsmith')(__dirname)
  .use(linkcheck())
  .build();

Because metalsmith-linkcheck will only check HTML pages, normally you will want to use metalsmith-linkcheck at the end of your build pipeline when all of your HTML pages have been generated. Note that metalsmith-linkcheck requires network access (duh). In addition, relative and root-relative local links are checked by looking for them in the metalsmith files array, and so this may not work if you using local links to things not included in your Metalsmith build.

Exceptions

metalsmith-linkcheck will ignore links that have or are descendants of elements with the class link_exception. For example, both of these links will not be checked:

<a href="broken.html" class="link_exception">This link will be skipped.</a>
<span class="link_exception"><a href="broken.html">So will this
one.</a></span>

Options

metalsmith-linkcheck does not require any options, but the following options are available:

verbose (optional)

(default: false)

timeout (s) (optional)

(default: 15 s)

Timeout after which a link will be marked as down. 15 s by default.

failWithoutNetwork (optional)

(default : true)

If set, metalsmith-linkcheck will fail if no network connection is available. Otherwise, it will still check internal links before exiting. Note in this case that external links will not be reported as failing.

failMissing (optional)

(default: false)

If set the metalsmith build process will halt if links are missing.

cacheChecks (optional)

(default: true)

If set metalsmith-linkcheck will record when external links succeed in checkFile and not repeat the check for an interval set by recheckMinutes.

recheckMinutes (optional)

(default : 1440 (24 hours))

Determines the length between successive link checks when cacheChecks is set to true.

checkFile (optional)

(default: .links_checked.json)

Path relative to the metalsmith source directory where metalsmith-linkcheck caches link check information. This will be removed from the build directory.

ignoreFile (optional)

(default: links_ignore.json)

Path relative to the metalsmith source directory to a JSON file containing an array of links to ignore. This will be removed from the build directory.

failFile (optional)

(default: links_failed.json)

Path relative to the metalsmith source directory to a JSON file where link failures are recorded. This will be removed from the build directory.