fix: post updating
This commit is contained in:
@@ -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) {}
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user