Skip to content

πŸ”— Recursively check a website for broken links

Notifications You must be signed in to change notification settings

styfle/links-awakening

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

24 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Photo of Link waking up

Links Awakening

Recursively check a website for broken links.

Usage

npx links-awakening 'https://styfle.dev'

Output

βœ… https://styfle.dev/
βœ… https://styfle.dev/projects
βœ… https://styfle.dev/blog
βœ… https://styfle.dev/contact
βœ… https://twitter.com/styfle
βœ… https://keybase.io/styfle
βœ… https://github.com/styfle
βœ… https://www.npmjs.com/~styfle
βœ… https://styfle.dev/blog/copee-released
βœ… http://googlechromereleases.blogspot.com/
βœ… https://developers.google.com/web/updates/
βœ… https://developers.google.com/web/updates/2015/04/cut-and-copy-commands
❌ http://zeroclipboard.org/ (status: 500, referer: https://styfle.dev/blog/copee-released)
βœ… http://styfle.github.io/copee/
βœ… https://styfle.dev/blog/d3js-graph-prod
❌ https://styfle.dev/slides/d3js.html (status: 404, referer: https://styfle.dev/blog/d3js-graph-prod)

Programmatic API

import { awaken, type AwakenResult } from 'links-awakening';

const onAwaken = ({ url, status }: AwakenResult) => {
  const icon = status >= 200 && status <= 299 ? 'βœ…' : '❌';
  console.log(`${icon} ${url}`);
};

const url = new URL('https://example.com/blog');

const results = new Map<string, AwakenResult>();

await awaken({ url, onAwaken, results });

console.log(`Done! Crawled ${results.size} links.`);