diff --git a/src/node/config.ts b/src/node/config.ts index c9bf2a14229..fca1df4757b 100644 --- a/src/node/config.ts +++ b/src/node/config.ts @@ -64,6 +64,13 @@ export interface UserConfig { * @experimental */ mpa?: boolean + + /** + * Don't fail builds due to dead links. + * + * @default false + */ + ignoreDeadLinks?: boolean } export type RawConfigExports = @@ -74,7 +81,13 @@ export type RawConfigExports = export interface SiteConfig 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 diff --git a/src/node/plugin.ts b/src/node/plugin.ts index e3f141313ef..a5fb7cceecc 100644 --- a/src/node/plugin.ts +++ b/src/node/plugin.ts @@ -44,7 +44,8 @@ export async function createVitePressPlugin( site, vue: userVuePluginOptions, vite: userViteConfig, - pages + pages, + ignoreDeadLinks } = siteConfig let markdownToVue: Awaited> @@ -153,7 +154,7 @@ export async function createVitePressPlugin( }, renderStart() { - if (hasDeadLinks) { + if (hasDeadLinks && !ignoreDeadLinks) { throw new Error(`One or more pages contain dead links.`) } },