diff --git a/src/utils/readsFromBookmarks.ts b/src/utils/readsFromBookmarks.ts index 033ef479..2fc493c4 100644 --- a/src/utils/readsFromBookmarks.ts +++ b/src/utils/readsFromBookmarks.ts @@ -2,6 +2,9 @@ import { Bookmark, IndividualBookmark } from '../types/bookmarks' import { ReadItem } from '../services/readsService' import { classifyBookmarkType } from './bookmarkTypeClassifier' import { KINDS } from '../config/kinds' +import { Helpers } from 'applesauce-core' + +const { getArticleTitle, getArticleImage, getArticlePublished, getArticleSummary } = Helpers /** * Derives ReadItems from bookmarks for Nostr articles (kind:30023). @@ -19,6 +22,12 @@ export function deriveReadsFromBookmarks(bookmarks: Bookmark[]): ReadItem[] { if (bookmarkType === 'article' && bookmark.kind === KINDS.BlogPost) { const coordinate = bookmark.id // Already in coordinate format + // Extract metadata from event if available + const title = bookmark.event ? getArticleTitle(bookmark.event) : bookmark.title + const summary = bookmark.event ? getArticleSummary(bookmark.event) : bookmark.summary + const image = bookmark.event ? getArticleImage(bookmark.event) : bookmark.image + const published = bookmark.event ? getArticlePublished(bookmark.event) : undefined + const item: ReadItem = { id: coordinate, source: 'bookmark', @@ -26,9 +35,10 @@ export function deriveReadsFromBookmarks(bookmarks: Bookmark[]): ReadItem[] { readingProgress: 0, readingTimestamp: bookmark.added_at || bookmark.created_at, event: bookmark.event, - title: bookmark.title, - summary: bookmark.summary, - image: bookmark.image, + title: title || 'Untitled', + summary, + image, + published, author: bookmark.pubkey, url: bookmark.url }