From 19b0758a04e9fb7863b3a961024dfe1137fbe928 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Sat, 25 Jun 2022 23:14:16 +0530 Subject: [PATCH] feat(build): allow ignoring dead links (#586) (#793) --- src/node/config.ts | 18 ++++++++++++++++-- src/node/plugin.ts | 5 +++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/node/config.ts b/src/node/config.ts index c9bf2a14..fca1df47 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 e3f14131..a5fb7cce 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.`) } },