fix: post updating

This commit is contained in:
DIYgod
2023-05-03 21:24:49 +01:00
parent e3f6717f08
commit 70f494766b
2 changed files with 6 additions and 2 deletions
+2 -1
View File
@@ -20,6 +20,7 @@ import { ExpandedNote, PageVisibilityEnum } from "~/lib/types"
export async function checkPageSlug(input: {
slug: string
characterId?: number
noteId?: number
}) {
if (!input.characterId) {
return "Character not found"
@@ -33,7 +34,7 @@ export async function checkPageSlug(input: {
slug: input.slug,
characterId: input.characterId,
})
if (page) {
if (page && page.noteId !== input.noteId) {
return `Slug "${input.slug}" has already been used`
}
} catch (error) {}
+4 -1
View File
@@ -209,6 +209,7 @@ export default function SubdomainEditor() {
const check = await checkPageSlug({
slug: values.slug || defaultSlug,
characterId: site.data?.characterId,
noteId: page?.data?.noteId,
})
if (check) {
toast.error(check)
@@ -219,7 +220,9 @@ export default function SubdomainEditor() {
tags: uniqueTags,
slug: values.slug || defaultSlug,
siteId: subdomain,
...(visibility === PageVisibilityEnum.Draft ? {} : { pageId: pageId }),
...(visibility === PageVisibilityEnum.Draft
? {}
: { pageId: `${page?.data?.characterId}-${page?.data?.noteId}` }),
isPost: isPost,
published,
externalUrl: