From cfe77f98d627995f2e1320cf0ddc248b90f405f0 Mon Sep 17 00:00:00 2001 From: Jake Jarvis Date: Tue, 15 Apr 2025 09:30:20 -0400 Subject: [PATCH] experimental prefetching on hover for common links --- app/notes/[slug]/counter.tsx | 1 + app/notes/[slug]/page.tsx | 2 +- app/notes/page.tsx | 6 +++- components/Header/Header.tsx | 2 +- components/Link/Link.tsx | 12 +++++-- components/MenuItem/MenuItem.tsx | 1 + lib/env.ts | 2 +- next.config.ts | 1 + package.json | 2 +- pnpm-lock.yaml | 58 ++++++++++++++++---------------- 10 files changed, 50 insertions(+), 37 deletions(-) diff --git a/app/notes/[slug]/counter.tsx b/app/notes/[slug]/counter.tsx index becf840f..bda16661 100644 --- a/app/notes/[slug]/counter.tsx +++ b/app/notes/[slug]/counter.tsx @@ -4,6 +4,7 @@ import CountUp from "../../../components/CountUp"; import redis from "../../../lib/redis"; const HitCounter = async ({ slug }: { slug: string }) => { + // ensure this component isn't triggered by prerenders and/or preloads await connection(); try { diff --git a/app/notes/[slug]/page.tsx b/app/notes/[slug]/page.tsx index 8288d20d..6a61fd40 100644 --- a/app/notes/[slug]/page.tsx +++ b/app/notes/[slug]/page.tsx @@ -125,7 +125,7 @@ const Page = async ({ params }: { params: Promise<{ slug: string }> }) => { className={styles.metaItem} style={{ // fix potential layout shift when number of hits loads - minWidth: "7em", + minWidth: "6em", marginRight: 0, }} > diff --git a/app/notes/page.tsx b/app/notes/page.tsx index c0ccac52..20a7796a 100644 --- a/app/notes/page.tsx +++ b/app/notes/page.tsx @@ -40,7 +40,11 @@ const Page = async () => {
  • ))} diff --git a/components/Header/Header.tsx b/components/Header/Header.tsx index 734a9f8d..950c457d 100644 --- a/components/Header/Header.tsx +++ b/components/Header/Header.tsx @@ -15,7 +15,7 @@ const Header = ({ className, ...rest }: HeaderProps) => { return (