Disable prefetching by default on HackCards and otherHacks

This commit is contained in:
Jared Schoeny
2026-07-21 18:03:17 -06:00
parent 92c86e80af
commit 3445ba04a5
3 changed files with 17 additions and 2 deletions

View File

@@ -558,6 +558,7 @@ export default async function HackDetail({ params }: HackDetailProps) {
<li key={otherHack.slug}>
<Link
href={`/hack/${otherHack.slug}`}
prefetch={false}
target="_blank"
className="group block hover:text-foreground"
>

View File

@@ -247,7 +247,7 @@ export default async function Home() {
</div>
<div className="grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3">
{hackData.map((hack) => (
<HackCard key={hack.slug} hack={hack} />
<HackCard key={hack.slug} hack={hack} prefetch={true} />
))}
</div>
<div className="sm:hidden flex justify-center mt-6">

View File

@@ -13,6 +13,7 @@ import { FaRegImages } from "react-icons/fa6";
import { ImDownload } from "react-icons/im";
import { RiArchiveStackFill } from "react-icons/ri";
import type { Database } from "@/types/db";
import type { LinkProps } from "next/link";
export interface HackCardAttributes {
slug: string;
@@ -29,7 +30,19 @@ export interface HackCardAttributes {
completion_status?: Database["public"]["Enums"]["Completion Status"] | null;
};
export default function HackCard({ hack, clickable = true, className = "" }: { hack: HackCardAttributes; clickable?: boolean; className?: string }) {
interface HackCardProps {
hack: HackCardAttributes;
clickable?: boolean;
prefetch?: LinkProps["prefetch"];
className?: string;
}
export default function HackCard({
hack,
clickable = true,
prefetch = false,
className = "",
}: HackCardProps) {
const isArchive = hack.is_archive;
const { isLinked, hasPermission, hasCached } = useBaseRoms();
const match = baseRoms.find((r) => r.id === hack.baseRomId);
@@ -222,6 +235,7 @@ export default function HackCard({ hack, clickable = true, className = "" }: { h
href={`/hack/${hack.slug}`}
className={`group block ${className}`.trim()}
draggable={false}
prefetch={prefetch}
onDragStart={(e) => {
e.preventDefault();
}}