feat: missing slug in editor

This commit is contained in:
DIYgod 2023-08-26 02:54:08 +01:00
parent be1825fbf7
commit 0fcb1d8ce9
No known key found for this signature in database
2 changed files with 6 additions and 7 deletions

View File

@ -94,9 +94,10 @@ export const expandCrossbellNote = async ({
...new Set(expandedNote.metadata.content.images),
]
if (!disableAutofill) {
expandedNote.metadata.content.slug = getNoteSlug(expandedNote)
}
expandedNote.metadata.content.slug = getNoteSlug(
expandedNote,
disableAutofill,
)
if (
!expandedNote.metadata.content.date_published &&
expandedNote.noteId &&

View File

@ -27,13 +27,11 @@ export const getSiteLink = ({
return `${IS_PROD ? "https" : "http"}://${subdomain}.${OUR_DOMAIN}`
}
export const getNoteSlug = (note: NoteEntity) => {
export const getNoteSlug = (note: NoteEntity, disableAutofill?: boolean) => {
return encodeURIComponent(
note.metadata?.content?.attributes?.find(
(a) => a?.trait_type === "xlog_slug",
)?.value ||
note.metadata?.content?.title ||
"",
)?.value || (disableAutofill ? "" : note.metadata?.content?.title || ""),
)
}