fix: change local post prefix, fix mustLocal in getPage

This commit is contained in:
DIYgod
2023-07-08 15:49:56 +01:00
parent e72170a4bc
commit 90456a3e0c
4 changed files with 7 additions and 7 deletions
@@ -97,14 +97,14 @@ export default function SubdomainEditor() {
let key
if (!pageId) {
const randomId = nanoid()
key = `draft-${site.data?.characterId}-local-${randomId}`
key = `draft-${site.data?.characterId}-!local-${randomId}`
setDraftKey(key)
queryClient.invalidateQueries([
"getPagesBySite",
site.data?.characterId,
])
router.replace(
`/dashboard/${subdomain}/editor?id=local-${randomId}&type=${searchParams?.get(
`/dashboard/${subdomain}/editor?id=!local-${randomId}&type=${searchParams?.get(
"type",
)}`,
)
@@ -114,7 +114,7 @@ export default function SubdomainEditor() {
setDraftKey(key)
setDefaultSlug(
key
.replace(`draft-${site.data?.characterId}-local-`, "")
.replace(`draft-${site.data?.characterId}-!local-`, "")
.replace(`draft-${site.data?.characterId}-`, ""),
)
}
+2 -2
View File
@@ -112,7 +112,7 @@ export const PagesManager = ({ isPost }: { isPost: boolean }) => {
const file = (await readFiles(e.target?.files))?.[0]
if (file) {
const id = nanoid()
const key = `draft-${site.data?.characterId}-local-${id}`
const key = `draft-${site.data?.characterId}-!local-${id}`
setStorage(key, {
date: +new Date(),
values: {
@@ -130,7 +130,7 @@ export const PagesManager = ({ isPost }: { isPost: boolean }) => {
site.data?.characterId,
])
router.push(
`/dashboard/${subdomain}/editor?id=local-${id}&type=${
`/dashboard/${subdomain}/editor?id=!local-${id}&type=${
isPost ? "post" : "page"
}`,
)
+1 -1
View File
@@ -11,7 +11,7 @@ export const getDefaultSlug = (title: string, id?: string) => {
?.filter((word) => word)
?.join("-")
?.replace(/\s+/g, "-") ||
id?.replace(`local-`, "") ||
id?.replace(`!local-`, "")?.replace(`local-`, "") ||
""
generated = generated.replace(/[^a-zA-Z0-9\s-_]/g, "")
+1 -1
View File
@@ -312,7 +312,7 @@ export async function getPage<TRender extends boolean = false>(input: {
noteId?: number
handle?: string // In order to be compatible with old drafts
}) {
const mustLocal = input.slug?.startsWith("local-") && !input.noteId
const mustLocal = input.slug?.startsWith("!local-") && !input.noteId
let page: NoteEntity | null = null