feat(build): allow ignoring only localhost dead links (#1821)

pull/1825/head
Divyansh Singh 2 years ago committed by GitHub
parent 9986f6ce52
commit fe52fa3420
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -86,10 +86,10 @@ type HeadConfig =
## ignoreDeadLinks ## ignoreDeadLinks
- Type: `boolean` - Type: `boolean | 'localhostLinks'`
- Default: `false` - Default: `false`
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. When set to `localhostLinks`, the build will fail on dead links, but won't check `localhost` links.
```ts ```ts
export default { export default {

@ -73,7 +73,7 @@ export interface UserConfig<ThemeConfig = any>
* *
* @default false * @default false
*/ */
ignoreDeadLinks?: boolean ignoreDeadLinks?: boolean | 'localhostLinks'
/** /**
* @experimental * @experimental

@ -115,7 +115,10 @@ export async function createMarkdownToVueRenderFn(
for (let url of links) { for (let url of links) {
if (/\.(?!html|md)\w+($|\?)/i.test(url)) continue if (/\.(?!html|md)\w+($|\?)/i.test(url)) continue
if (url.replace(EXTERNAL_URL_RE, '').startsWith('//localhost:')) { if (
siteConfig?.ignoreDeadLinks !== 'localhostLinks' &&
url.replace(EXTERNAL_URL_RE, '').startsWith('//localhost:')
) {
recordDeadLink(url) recordDeadLink(url)
continue continue
} }

Loading…
Cancel
Save