37 lines
1.4 KiB
TypeScript
37 lines
1.4 KiB
TypeScript
import { getPubNewsletter } from "@/app/actions/NewsletterActions";
|
|
import { notFound } from "next/navigation";
|
|
|
|
export default async function NewsletterPage({ params }: { params: Promise<{ id: string }>; }) { // next passes in params object when this comp is called
|
|
const { id } = await params; // [id] catches the value from the url and gives it a param value with the key of id
|
|
const newsletter = await getPubNewsletter(id);
|
|
|
|
if (!newsletter) { // otherwise tries to reference things that dont exist
|
|
notFound();
|
|
}
|
|
|
|
return (
|
|
<main className="mx-auto w-full max-w-3xl px-6 py-10">
|
|
<article>
|
|
<h1 className="text-4xl font-bold tracking-tight">
|
|
{newsletter.title}
|
|
</h1>
|
|
|
|
<p className="mt-3 text-sm text-base-content/60">
|
|
By {newsletter.author.name || "Unnamed author"}
|
|
</p>
|
|
|
|
{newsletter.imageUrl && (
|
|
<img
|
|
src={newsletter.imageUrl}
|
|
alt={newsletter.title}
|
|
className="mt-6 h-auto w-full rounded-lg"
|
|
/>
|
|
)}
|
|
|
|
<div className="mt-8 whitespace-pre-wrap leading-relaxed">
|
|
{newsletter.content}
|
|
</div>
|
|
</article>
|
|
</main>
|
|
);
|
|
} |