From 0fcb1d8ce91e299a4d4346f70a3acf5248368220 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Sat, 26 Aug 2023 02:54:08 +0100 Subject: [PATCH] feat: missing slug in editor --- src/lib/expand-unit.ts | 7 ++++--- src/lib/helpers.ts | 6 ++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/lib/expand-unit.ts b/src/lib/expand-unit.ts index 07003545..2cf7d12f 100644 --- a/src/lib/expand-unit.ts +++ b/src/lib/expand-unit.ts @@ -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 && diff --git a/src/lib/helpers.ts b/src/lib/helpers.ts index 03e998dd..d7e01563 100644 --- a/src/lib/helpers.ts +++ b/src/lib/helpers.ts @@ -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 || ""), ) }