Skip to content

Commit

Permalink
fix: fix link prefetch
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Dec 3, 2020
1 parent 7c83105 commit ade6ddd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/client/app/components/Content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
4 changes: 2 additions & 2 deletions src/client/app/composables/preFetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ade6ddd

Please sign in to comment.