Skip to content

Commit

Permalink
feat(build): allow ignoring only localhost dead links (#1821)
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd authored Jan 20, 2023
1 parent 9986f6c commit fe52fa3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docs/config/app-configs.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ type HeadConfig =
## ignoreDeadLinks
- Type: `boolean`
- Type: `boolean | 'localhostLinks'`
- 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
export default {
Expand Down
2 changes: 1 addition & 1 deletion src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export interface UserConfig<ThemeConfig = any>
*
* @default false
*/
ignoreDeadLinks?: boolean
ignoreDeadLinks?: boolean | 'localhostLinks'

/**
* @experimental
Expand Down
5 changes: 4 additions & 1 deletion src/node/markdownToVue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ export async function createMarkdownToVueRenderFn(
for (let url of links) {
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)
continue
}
Expand Down

0 comments on commit fe52fa3

Please sign in to comment.