mirror of
https://github.com/dergigi/boris.git
synced 2025-12-26 02:54:29 +01:00
- Add summary field when converting ArticleContent to ReadableContent - Fix contentLoader.ts to include article.summary - Fix useArticleLoader.ts to include article.summary - Article summaries now properly display in reader header - Resolves missing summary display for kind:30023 articles
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { nip19 } from 'nostr-tools'
|
|
import { RelayPool } from 'applesauce-relay'
|
|
import { fetchArticleByNaddr } from '../services/articleService'
|
|
import { fetchReadableContent, ReadableContent } from '../services/readerService'
|
|
|
|
export interface BookmarkReference {
|
|
id: string
|
|
kind: number
|
|
tags: string[][]
|
|
pubkey: string
|
|
}
|
|
|
|
export async function loadContent(
|
|
url: string,
|
|
relayPool: RelayPool,
|
|
bookmark?: BookmarkReference
|
|
): Promise<ReadableContent> {
|
|
// Check if this is a kind:30023 article
|
|
if (bookmark && bookmark.kind === 30023) {
|
|
const dTag = bookmark.tags.find(t => t[0] === 'd')?.[1] || ''
|
|
|
|
if (dTag !== undefined && bookmark.pubkey) {
|
|
const pointer = {
|
|
identifier: dTag,
|
|
kind: 30023,
|
|
pubkey: bookmark.pubkey,
|
|
}
|
|
const naddr = nip19.naddrEncode(pointer)
|
|
const article = await fetchArticleByNaddr(relayPool, naddr)
|
|
|
|
return {
|
|
title: article.title,
|
|
markdown: article.markdown,
|
|
image: article.image,
|
|
summary: article.summary,
|
|
url: `nostr:${naddr}`
|
|
}
|
|
} else {
|
|
throw new Error('Invalid article reference - missing d tag or pubkey')
|
|
}
|
|
} else {
|
|
// For regular URLs, fetch readable content
|
|
return await fetchReadableContent(url)
|
|
}
|
|
}
|