Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

. #859

Merged
merged 2 commits into from
Jun 25, 2022
Merged

. #859

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/node/config.ts
Original file line number Diff line number Diff line change
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
2 changes: 1 addition & 1 deletion src/node/markdown/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const createMarkdownRenderer = async (
const md = MarkdownIt({
html: true,
linkify: true,
highlight: await highlight(options.theme),
highlight: options.highlight || (await highlight(options.theme)),
...options
}) as MarkdownRenderer

Expand Down
5 changes: 3 additions & 2 deletions src/node/plugin.ts
Original file line number Diff line number Diff line change
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