env.links becomes an array of { url, raw, loc } objects: the normalized
href, the destination as authored (decoded), and the exact position it was
authored at — including inside `<!-- @include -->`-ed files, which
previously reported the including page with a line in the expanded text.
Reports print the URL as written plus the resolved page path
(`(resolves to /x) in file.md:12:5`), fixing #4992 and #3774's halves of
the same complaint, and table-cell links (which had no line at all) and
links past the first line of a paragraph now carry exact positions.
Carries over the raw-URL reporting and test matrix from #5316.
BREAKING CHANGE: `env.links` entries are objects instead of strings and
`env.linkLines` is gone; `ignoreDeadLinks` strings, regexes and filter
functions now match the link as authored instead of the normalized encoded
URL, and filter functions receive a `{ file, line, column, url }` context
object instead of the source path string; `MarkdownCompileResult.deadLinks`
entries gained `resolved`/`column` and their `url` is now the authored
form. The markdown-it rule names `github-alerts`, `snippet` and
`vitepress_link_lines` are renamed/replaced by `vp_`-prefixed rules.
Co-authored-by: Bjorn Lu <34116392+bluwy@users.noreply.github.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
When set to `true`, VitePress will not fail builds due to dead links.
When set to `true`, VitePress will not fail builds due to dead links.
@ -533,20 +533,33 @@ export default {
}
}
```
```
It can also be an array of exact url string, regex patterns, or custom filter functions.
It can also be an array of exact url strings, regex patterns, or custom filter functions. These match the link **as authored in the source**, decoded — for example, a link written as `[docs](./guide/index.md)` is matched as `./guide/index.md`.
```ts
```ts
export default {
export default {
ignoreDeadLinks: [
ignoreDeadLinks: [
// ignore exact url "/playground"
// ignore links written exactly as "/playground"
'/playground',
'/playground',
// ignore all localhost links
// ignore all localhost links
/^https?:\/\/localhost/,
/^https?:\/\/localhost/,
// ignore all links include "/repl/""
// ignore all links including "/repl/"
/\/repl\//,
/\/repl\//,
// custom function, ignore all links include "ignore"
// custom function, ignore all links including "ignore"
(url) => {
(link) => {
return url.toLowerCase().includes('ignore')
return link.toLowerCase().includes('ignore')
}
]
}
```
Filter functions also receive the link's context — the absolute path of the file it was authored in (for links inside [included markdown](../guide/markdown#markdown-file-inclusion), the included file itself), its position, and the URL the check resolved: