16 lines
449 B
TypeScript
16 lines
449 B
TypeScript
|
|
import { notFound } from "next/navigation";
|
||
|
|
|
||
|
|
export default async function PostDetail({ params }: { params: { id: string } }) {
|
||
|
|
const res = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL ?? ""}/api/posts/${params.id}`, { cache: "no-store" });
|
||
|
|
if (!res.ok) return notFound();
|
||
|
|
const { post } = await res.json();
|
||
|
|
return (
|
||
|
|
<div>
|
||
|
|
<h1>{post.title}</h1>
|
||
|
|
<p style={{ whiteSpace: "pre-wrap" }}>{post.content}</p>
|
||
|
|
</div>
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|