feat(client): allow disabling link auto-prefetching (#3220)

Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com>
pull/3233/head
bonyuta0204 8 months ago committed by GitHub
parent 8438e971dd
commit 563dc89975
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -48,7 +48,7 @@ const VitePressApp = defineComponent({
})
})
if (import.meta.env.PROD) {
if (import.meta.env.PROD && site.value.router.prefetchLinks) {
// in prod mode, enable intersectionObserver based pre-fetch
usePrefetch()
}

@ -243,6 +243,9 @@ export async function resolveSiteData(
description: userConfig.description || 'A VitePress site',
base: userConfig.base ? userConfig.base.replace(/([^/])$/, '$1/') : '/',
head: resolveSiteDataHead(userConfig),
router: {
prefetchLinks: userConfig.router?.prefetchLinks ?? true
},
appearance: userConfig.appearance ?? true,
themeConfig: userConfig.themeConfig || {},
locales: userConfig.locales || {},

@ -69,6 +69,10 @@ export interface UserConfig<ThemeConfig = any>
locales?: LocaleConfig<ThemeConfig>
router?: {
prefetchLinks?: boolean
}
appearance?:
| boolean
| 'dark'
@ -201,6 +205,7 @@ export interface SiteConfig<ThemeConfig = any>
| 'vue'
| 'vite'
| 'shouldPreload'
| 'router'
| 'mpa'
| 'metaChunk'
| 'lastUpdated'

3
types/shared.d.ts vendored

@ -126,6 +126,9 @@ export interface SiteData<ThemeConfig = any> {
locales: LocaleConfig<ThemeConfig>
localeIndex?: string
contentProps?: Record<string, any>
router: {
prefetchLinks: boolean
}
}
export type HeadConfig =

Loading…
Cancel
Save