diff --git a/src/app/blog/write/action.ts b/src/app/blog/write/action.ts index 17cb0b7..f2c1733 100644 --- a/src/app/blog/write/action.ts +++ b/src/app/blog/write/action.ts @@ -46,6 +46,7 @@ export async function savePostServer( if (!post) { throw new Error("Post not found"); } + await prisma.post.delete({ where: { slug: existingSlug } }); for (const tag of post.tags) { const postsWithTag = await prisma.post.count({ where: { tags: { some: { id: tag.id } } }, @@ -54,7 +55,6 @@ export async function savePostServer( await prisma.tag.delete({ where: { id: tag.id } }); } } - await prisma.post.delete({ where: { slug: existingSlug } }); } await prisma.post.create({