From 4d64a3464faf35ebcc5477568232279a6c819ba8 Mon Sep 17 00:00:00 2001 From: ngc2207 Date: Tue, 12 Nov 2024 18:25:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=9C=A8=E7=BC=96=E8=BE=91=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=89=87=E6=AE=B5=E5=8A=9F=E8=83=BD=E4=B8=AD=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=B7=AF=E5=BE=84=E9=87=8D=E6=96=B0=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E5=AE=9E=E7=8E=B0=E9=9D=99=E6=80=81=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/actions/index.ts | 1 + src/app/snippets/[id]/page.tsx | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/actions/index.ts b/src/actions/index.ts index 25a5005..4d59494 100644 --- a/src/actions/index.ts +++ b/src/actions/index.ts @@ -10,6 +10,7 @@ export async function editSnippet(id: number, code: string) { data: { code }, }); + revalidatePath(`/snippets/${id}`); redirect(`/snippets/${id}`); } diff --git a/src/app/snippets/[id]/page.tsx b/src/app/snippets/[id]/page.tsx index 7f1495e..4719919 100644 --- a/src/app/snippets/[id]/page.tsx +++ b/src/app/snippets/[id]/page.tsx @@ -47,3 +47,13 @@ export default async function SnippetShowPage(props: SnippetShowPageProps) { ); } + +export async function generateStaticParams() { + const snippets = await db.snippet.findMany(); + + return snippets.map((snippet) => { + return { + id: snippet.id.toString(), + }; + }); +}