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

pull/859/head
Divyansh Singh 3 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 * @experimental
*/ */
mpa?: boolean mpa?: boolean
/**
* Don't fail builds due to dead links.
*
* @default false
*/
ignoreDeadLinks?: boolean
} }
export type RawConfigExports<ThemeConfig = any> = export type RawConfigExports<ThemeConfig = any> =
@ -74,7 +81,13 @@ export type RawConfigExports<ThemeConfig = any> =
export interface SiteConfig<ThemeConfig = any> export interface SiteConfig<ThemeConfig = any>
extends Pick< extends Pick<
UserConfig, UserConfig,
'markdown' | 'vue' | 'vite' | 'shouldPreload' | 'mpa' | 'lastUpdated' | 'markdown'
| 'vue'
| 'vite'
| 'shouldPreload'
| 'mpa'
| 'lastUpdated'
| 'ignoreDeadLinks'
> { > {
root: string root: string
srcDir: string srcDir: string
@ -152,7 +165,8 @@ export async function resolveConfig(
vue: userConfig.vue, vue: userConfig.vue,
vite: userConfig.vite, vite: userConfig.vite,
shouldPreload: userConfig.shouldPreload, shouldPreload: userConfig.shouldPreload,
mpa: !!userConfig.mpa mpa: !!userConfig.mpa,
ignoreDeadLinks: userConfig.ignoreDeadLinks
} }
return config return config

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

Loading…
Cancel
Save