From 60b57ded7f92d22d70a234d9e7308bf9018ecc03 Mon Sep 17 00:00:00 2001 From: ngc2207 Date: Tue, 12 Nov 2024 15:21:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=8D=95=E4=B8=AA?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=89=87=E6=AE=B5=E5=B1=95=E7=A4=BA=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=9A=84=E6=95=B0=E6=8D=AE=E5=BA=93=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=92=8C404=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/snippets/[id]/page.tsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/app/snippets/[id]/page.tsx b/src/app/snippets/[id]/page.tsx index ad2f928..5280a77 100644 --- a/src/app/snippets/[id]/page.tsx +++ b/src/app/snippets/[id]/page.tsx @@ -1,3 +1,6 @@ +import { db } from "@/db"; +import { notFound } from "next/navigation"; + interface SnippetShowPageProps { params: Promise<{ id: string; @@ -5,6 +8,16 @@ interface SnippetShowPageProps { } export default async function SnippetShowPage(props: SnippetShowPageProps) { - const { id } = await props.params; - return
Show a snippet: {id}
; + const params = await props.params; + const snippet = await db.snippet.findFirst({ + where: { + id: parseInt(params.id), + }, + }); + + if (!snippet) { + return notFound(); + } + + return
Show a snippet: {snippet.title}
; }