fix: fix link prefetch

pull/183/head
Evan You 4 years ago
parent 7c83105e51
commit ade6dddbb5

@ -6,7 +6,7 @@ export const Content = {
setup() {
const route = useRoute()
if (process.env.NODE_ENV === 'production') {
if (import.meta.env.PROD) {
// in prod mode, enable intersectionObserver based pre-fetch
usePrefetch()
}

@ -72,10 +72,10 @@ export function usePrefetch() {
})
rIC(() => {
document.querySelectorAll('.vitepress-content a').forEach((link) => {
document.querySelectorAll('#app a').forEach((link) => {
const { target, hostname, pathname } = link as HTMLAnchorElement
if (
// only prefetch same page navigation, since a new page will load
// only prefetch same tab navigation, since a new tab will load
// the lean js chunk instead.
target !== `_blank` &&
// only prefetch inbound links

Loading…
Cancel
Save