@waylay/ssblc
v0.5.6
Published
Static Site Broken Link Chacker: A broken-link checker for static sites, like the ones generated with docsify
Downloads
24
Readme
@waylay/ssblc
Static Site Broken Link Checker
A broken-link checker for static sites, like the ones generated with docsify that can get used, for example, for CI purposes on docsify docs (this is what I've developed it for).
It recursively checks internal links found on the static website (until every internal link is checked) and (without recursion) outgoing links. This is achieved by finding href attributes in the HTML, meaning also stylesheets included with <link href="some-file.css"> get checked.
Installation
You can either run it by just using npx, in which case you won't have to install it, or first install it with
npm install -g @waylay/ssblcUsage
When you are in the folder of your static website (i.e., there is an index.html in this folder), simply run
ssblcafter which the checker will begin its work.
To use it with npx, simply run
npx @waylay/ssblcAlternatively, you can also specify an absolute or relative path to the directory of the site, e.g., like this:
ssblc --dir ../my-siteIf not present, the checker will use the current working directory as the base directory.
Additional Options
--context [file]
Loads a JSON file with context variables for link replacement. The file should contain a JSON object with the following structure:
{
"vars": {
"some-key": "some-value",
"another-key": "another-value"
}
}The context variables can be used in the href attributes of the HTML, e.g., <a href="{{vars.some-key}}">Some Link</a>.
--max-concurrent-checks [number]
Sets the maximum number of concurrent checks (default: 5).
--protocol-timeout [milliseconds]
Sets the protocol timeout for Puppeteer (default: 30000 ms).
--page-load-timeout [milliseconds]
Sets the page load timeout for Puppeteer (default: 30000 ms).
--port [number]
Sets the port number for the local server (default: 3000).
--ignore-statuses [statuses]
Comma-separated list of HTTP statuses to ignore (e.g., 401,403).
--dry-run
If present, exit with code 0 even if errors are found.
Examples
Check a static site in the current working directory
ssblcCheck a static site in a different directory
ssblc --dir ../my-siteCheck a static site with context variables
ssblc --context context.jsonCheck a static site using a different port number
ssblc --port 8080Check a static site using a different protocol timeout
ssblc --protocol-timeout 60000Check a static site using a different page load timeout
ssblc --page-load-timeout 60000Check a static site using a different maximum number of concurrent checks
ssblc --max-concurrent-checks 10Check a static site with ignored HTTP statuses
ssblc --ignore-statuses 401,403Check a static site and exit with code 0 even if errors are found
ssblc --dry-run