fix: fix link prefetch

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

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

@ -72,10 +72,10 @@ export function usePrefetch() {
}) })
rIC(() => { rIC(() => {
document.querySelectorAll('.vitepress-content a').forEach((link) => { document.querySelectorAll('#app a').forEach((link) => {
const { target, hostname, pathname } = link as HTMLAnchorElement const { target, hostname, pathname } = link as HTMLAnchorElement
if ( 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. // the lean js chunk instead.
target !== `_blank` && target !== `_blank` &&
// only prefetch inbound links // only prefetch inbound links

Loading…
Cancel
Save