import Article from "./models/article.ts"; import Profile from "./models/profile.ts"; import { isoDate } from "./dates.ts"; export async function profileAtomFeed( profile: Profile, articles: Article[], ): Promise { const feedId = `tag:${profile.nip05},nostr-p-${profile.pubkey}-k-30023`; const lastUpdate = articles.sort((a, b) => b.updatedAt - a.updatedAt)[0] ?.updatedAt; let articlesXml = ""; for (const article of articles) { const contentHtml = await article.buildContentHtml(); const articleId = `tag:${profile.nip05},nostr-p-${profile.pubkey}-d-${article.identifier}-k-30023`; articlesXml += ` ${articleId} ${article.title} ${isoDate(article.updatedAt)} ${isoDate(article.publishedAt)} ${article.summary} `; } return ` ${profile.name} on Nostr (Articles) ${feedId} ${isoDate(lastUpdate)} ${profile.avatarImageUrl} ${profile.name} ${profile.profileUrl} nostr:${profile.nprofile} ${articlesXml} `.trim(); } export function cleanContentHtml(html: string) { const cleanHtml = html.replace( /