diff --git a/src/models/page.model.ts b/src/models/page.model.ts index ae55aeff..8f7de68f 100644 --- a/src/models/page.model.ts +++ b/src/models/page.model.ts @@ -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) {} diff --git a/src/pages/dashboard/[subdomain]/editor.tsx b/src/pages/dashboard/[subdomain]/editor.tsx index f303cb16..b3e0fa03 100644 --- a/src/pages/dashboard/[subdomain]/editor.tsx +++ b/src/pages/dashboard/[subdomain]/editor.tsx @@ -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: