Skip to content

Commit

Permalink
scope to router
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed Nov 18, 2023
1 parent 42cf856 commit ee7f57e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/client/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const VitePressApp = defineComponent({
})
})

if (import.meta.env.PROD && site.value.prefetch) {
if (import.meta.env.PROD && site.value.router.prefetchLinks) {
// in prod mode, enable intersectionObserver based pre-fetch
usePrefetch()
}
Expand Down
4 changes: 3 additions & 1 deletion src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ export async function resolveSiteData(
description: userConfig.description || 'A VitePress site',
base: userConfig.base ? userConfig.base.replace(/([^/])$/, '$1/') : '/',
head: resolveSiteDataHead(userConfig),
prefetch: userConfig.prefetch ?? true,
router: {
prefetchLinks: userConfig.router?.prefetchLinks ?? true
},
appearance: userConfig.appearance ?? true,
themeConfig: userConfig.themeConfig || {},
locales: userConfig.locales || {},
Expand Down
6 changes: 4 additions & 2 deletions src/node/siteConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ export interface UserConfig<ThemeConfig = any>

locales?: LocaleConfig<ThemeConfig>

prefetch?: boolean
router?: {
prefetchLinks?: boolean
}

appearance?:
| boolean
Expand Down Expand Up @@ -203,7 +205,7 @@ export interface SiteConfig<ThemeConfig = any>
| 'vue'
| 'vite'
| 'shouldPreload'
| 'prefetch'
| 'router'
| 'mpa'
| 'metaChunk'
| 'lastUpdated'
Expand Down
4 changes: 3 additions & 1 deletion types/shared.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ export interface SiteData<ThemeConfig = any> {
dir: string
title: string
titleTemplate?: string | boolean
prefetch: boolean
description: string
head: HeadConfig[]
appearance:
Expand All @@ -127,6 +126,9 @@ export interface SiteData<ThemeConfig = any> {
locales: LocaleConfig<ThemeConfig>
localeIndex?: string
contentProps?: Record<string, any>
router: {
prefetchLinks: boolean
}
}

export type HeadConfig =
Expand Down

0 comments on commit ee7f57e

Please sign in to comment.