findDeadLinks #

Checks the links of every page against the routes, heading anchors and public files of the site, and returns the dead ones sorted by source and line.

Usage #

TypeScript
import { 
findDeadLinks
} from 'kawapress'
const
dead
=
findDeadLinks
(
[{
route
: '/a',
source
: '/a.md',
headings
: [],
links
: [{
href
: '/b',
target
: '/b',
line
: 3 }],
}], {
routes
: ['/a'],
headings
: new
Map
(),
publicFiles
: [] },
)

Parameters

pagesIterable<PageLinks>

The links and heading anchors of each page.

siteDeadLinkSite

The routes, heading anchors and public files the links can point to.

routesIterable<string>

Public routes of every page in the site.

headingsReadonlyMap<string, readonly string[]>

Heading IDs of each page, keyed by route.

publicFilesIterable<string>

Files in the public directory, as paths relative to it, for example /logo.png.

ignoreoptionalreadonly DeadLinkIgnore[]

Links to skip.

default []

Returns The dead links, sorted by source and line.

Full type signature
TypeScript
function findDeadLinks(
  pages: Iterable<PageLinks>,
  site: DeadLinkSite,
  ignore?: readonly DeadLinkIgnore[],
): DeadLink[]

Edit this page

Comments