feat(build): allow ignoring dead links (#586) (#793)

pull/859/head
Divyansh Singh 2 years ago committed by GitHub
parent ddf876d8e9
commit 19b0758a04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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> =
@ -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
@ -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

@ -44,7 +44,8 @@ export async function createVitePressPlugin(
site,
vue: userVuePluginOptions,
vite: userViteConfig,
pages
pages,
ignoreDeadLinks
} = siteConfig
let markdownToVue: Awaited<ReturnType<typeof createMarkdownToVueRenderFn>>
@ -153,7 +154,7 @@ export async function createVitePressPlugin(
},
renderStart() {
if (hasDeadLinks) {
if (hasDeadLinks && !ignoreDeadLinks) {
throw new Error(`One or more pages contain dead links.`)
}
},

Loading…
Cancel
Save