import { notFound } from "next/navigation";
import { eq } from "drizzle-orm";
import { db } from "@/db";
import { blogPosts } from "@/db/schema";
import { fmtDate } from "@/lib/format";
export default async function Post({ params }: { params: Promise<{ slug: string }> }) {
  const [p] = await db.select().from(blogPosts).where(eq(blogPosts.slug, (await params).slug));
  if (!p || !p.published) notFound();
  return <article className="container-x py-12 max-w-3xl">{/* eslint-disable-next-line @next/next/no-img-element */}{p.image && <img src={p.image} alt={p.title} className="rounded-3xl aspect-video object-cover w-full mb-8" />}<h1 className="text-3xl font-extrabold">{p.title}</h1><p className="text-sm text-slate-500 mt-2 mb-6">{fmtDate(p.createdAt)}</p><div className="prose-body">{p.body.split(/\n\n+/).map((t, i) => <p key={i}>{t}</p>)}</div></article>;
}
