// app/Projects/[id]/page.tsx "use client"; import { useParams } from "next/navigation"; import { useEffect, useState } from "react"; import Link from "next/link"; interface Project { id: string; title: string; description: string; link: string; } export default function ProjectDetail() { const params = useParams(); const { id } = params as { id: string }; const [project, setProject] = useState(null); useEffect(() => { if (id) { fetch("/data/projects.json") .then((res) => res.json()) .then((data: Project[]) => { const found = data.find((proj) => proj.id === id); setProject(found || null); // Log the project view fetch("/api/stats", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ type: "project_view", projectId: id }), }).catch((err) => console.error("Failed to log project view", err)); }); } }, [id]); if (!project) { return
Loading...
; } return (

{project.title}

{project.description}

Visit Project
); }