import type { ArticleMetadata } from './ogStore.js' export function escapeHtml(text: string): string { return text .replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"') .replace(/'/g, ''') } export function generateHtml(naddr: string, meta: ArticleMetadata | null): string { const baseUrl = 'https://read.withboris.com' const articleUrl = `${baseUrl}/a/${naddr}` const title = meta?.title || 'Boris – Read, Highlight, Explore' const description = meta?.summary || 'Your reading list for the Nostr world. A minimal nostr client for bookmark management with highlights.' const image = meta?.image?.startsWith('http') ? meta.image : `${baseUrl}${meta?.image || '/boris-social-1200.png'}` const author = meta?.author || 'Boris' const imageAlt = meta?.imageAlt || title // Generate article:tag meta tags const articleTags = meta?.tags && meta.tags.length > 0 ? meta.tags.map((tag) => ` `).join('\n') : '' return ` ${escapeHtml(title)} ${meta?.published ? ` ` : ''} ${articleTags} ` }