feat: 在编辑代码片段功能中添加路径重新验证,并实现静态参数生成

This commit is contained in:
ngc2207 2024-11-12 18:25:05 +08:00
parent 136425a0ea
commit 4d64a3464f
2 changed files with 11 additions and 0 deletions

View File

@ -10,6 +10,7 @@ export async function editSnippet(id: number, code: string) {
data: { code }, data: { code },
}); });
revalidatePath(`/snippets/${id}`);
redirect(`/snippets/${id}`); redirect(`/snippets/${id}`);
} }

View File

@ -47,3 +47,13 @@ export default async function SnippetShowPage(props: SnippetShowPageProps) {
</div> </div>
); );
} }
export async function generateStaticParams() {
const snippets = await db.snippet.findMany();
return snippets.map((snippet) => {
return {
id: snippet.id.toString(),
};
});
}