import { useLoaderData, Link } from "@remix-run/react"; import { ArrowLeftIcon } from "@heroicons/react/24/outline"; import { prisma } from "@/lib/prisma"; import { LoaderFunctionArgs } from "@remix-run/node"; import { Article } from "@prisma/client"; // Loader function to fetch article data export async function loader({ params }: LoaderFunctionArgs) { const { cid } = params; const article = await prisma.article.findUnique({ where: { cid }, }); if (!article) { throw new Response("Not Found", { status: 404 }); } return article; } const Page = () => { // Use the loader data const article = useLoaderData() as unknown as Article; return ( <>