diff --git a/app/routes/article.$cid.tsx b/app/routes/article.$cid.tsx new file mode 100644 index 0000000..cde3c30 --- /dev/null +++ b/app/routes/article.$cid.tsx @@ -0,0 +1,44 @@ +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 ( + <> + + + +
+ +
+ + ); +}; + +export default Page; diff --git a/app/routes/article.$slug.tsx b/app/routes/article.$slug.tsx deleted file mode 100644 index 62897de..0000000 --- a/app/routes/article.$slug.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { ArrowLeftIcon } from "@heroicons/react/24/outline"; -// page https://www.businessinsider.com/web3-music-platforms-blockchain-even-sound-iyk-streaming-services-artists-2023-9#:~:text=Web3%20music%20platforms%20are%20combining,and%20'create%20dope%20consumer%20experiences'&text=Web3%20music%20platforms%20are%20changing,and%20ways%20to%20reach%20fans. -import React from "react"; -import { Link } from "@remix-run/react"; - -const Page = () => { - // TODO: Explore based on the slug, we can also change the slug to be like the id or something the backend understands - // We can also pre-render the article from the backend - return ( - <> - - - -
- -
- - ); -}; - -export default Page;