feat: improve notification content

This commit is contained in:
codytseng
2025-01-09 14:49:52 +08:00
parent 9f0f39f480
commit be7712948a
4 changed files with 31 additions and 3 deletions

View File

@@ -215,3 +215,17 @@ export function extractImagesFromContent(content: string) {
contentWithoutImages = contentWithoutImages.replace(/\n{3,}/g, '\n\n').trim()
return { images, contentWithoutImages }
}
export function extractEmbeddedNotesFromContent(content: string) {
let c = content
const embeddedNotes: string[] = []
const embeddedNoteRegex = /nostr:(note1[a-z0-9]{58}|nevent1[a-z0-9]+|naddr1[a-z0-9]+)/g
;(c.match(embeddedNoteRegex) || []).forEach((note) => {
c = c.replace(note, '').trim()
embeddedNotes.push(note)
})
c = c.replace(/\n{3,}/g, '\n\n').trim()
return { embeddedNotes, contentWithoutEmbeddedNotes: c }
}