Skip to content

Commit

Permalink
feat(build): allow ignoring dead links (#586) (#793)
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed Jun 25, 2022
1 parent ddf876d commit 19b0758
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
18 changes: 16 additions & 2 deletions src/node/config.ts
Expand Up @@ -64,6 +64,13 @@ export interface UserConfig<ThemeConfig = any> {
* @experimental
*/
mpa?: boolean

/**
* Don't fail builds due to dead links.
*
* @default false
*/
ignoreDeadLinks?: boolean
}

export type RawConfigExports<ThemeConfig = any> =
Expand All @@ -74,7 +81,13 @@ export type RawConfigExports<ThemeConfig = any> =
export interface SiteConfig<ThemeConfig = any>
extends Pick<
UserConfig,
'markdown' | 'vue' | 'vite' | 'shouldPreload' | 'mpa' | 'lastUpdated'
| 'markdown'
| 'vue'
| 'vite'
| 'shouldPreload'
| 'mpa'
| 'lastUpdated'
| 'ignoreDeadLinks'
> {
root: string
srcDir: string
Expand Down Expand Up @@ -152,7 +165,8 @@ export async function resolveConfig(
vue: userConfig.vue,
vite: userConfig.vite,
shouldPreload: userConfig.shouldPreload,
mpa: !!userConfig.mpa
mpa: !!userConfig.mpa,
ignoreDeadLinks: userConfig.ignoreDeadLinks
}

return config
Expand Down
5 changes: 3 additions & 2 deletions src/node/plugin.ts
Expand Up @@ -44,7 +44,8 @@ export async function createVitePressPlugin(
site,
vue: userVuePluginOptions,
vite: userViteConfig,
pages
pages,
ignoreDeadLinks
} = siteConfig

let markdownToVue: Awaited<ReturnType<typeof createMarkdownToVueRenderFn>>
Expand Down Expand Up @@ -153,7 +154,7 @@ export async function createVitePressPlugin(
},

renderStart() {
if (hasDeadLinks) {
if (hasDeadLinks && !ignoreDeadLinks) {
throw new Error(`One or more pages contain dead links.`)
}
},
Expand Down

0 comments on commit 19b0758

Please sign in to comment.