Skip to content

Commit fe52fa3

Browse files
authoredJan 20, 2023
feat(build): allow ignoring only localhost dead links (#1821)
1 parent 9986f6c commit fe52fa3

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed
 

‎docs/config/app-configs.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ type HeadConfig =
8686
8787
## ignoreDeadLinks
8888
89-
- Type: `boolean`
89+
- Type: `boolean | 'localhostLinks'`
9090
- Default: `false`
9191
92-
When set to `true`, VitePress will not fail builds due to dead links.
92+
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.
9393
9494
```ts
9595
export default {

‎src/node/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export interface UserConfig<ThemeConfig = any>
7373
*
7474
* @default false
7575
*/
76-
ignoreDeadLinks?: boolean
76+
ignoreDeadLinks?: boolean | 'localhostLinks'
7777

7878
/**
7979
* @experimental

‎src/node/markdownToVue.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ export async function createMarkdownToVueRenderFn(
115115
for (let url of links) {
116116
if (/\.(?!html|md)\w+($|\?)/i.test(url)) continue
117117

118-
if (url.replace(EXTERNAL_URL_RE, '').startsWith('//localhost:')) {
118+
if (
119+
siteConfig?.ignoreDeadLinks !== 'localhostLinks' &&
120+
url.replace(EXTERNAL_URL_RE, '').startsWith('//localhost:')
121+
) {
119122
recordDeadLink(url)
120123
continue
121124
}

0 commit comments

Comments
 (0)
Please sign in to comment.