import { localizeDate } from "./dates.ts"; import Article from "./models/article.ts"; import Profile from "./models/profile.ts"; export function htmlLayout(title: string, body: string, profile: Profile) { return ` ${title} ${body} `; } export function articleHtml(article: Article, profile: Profile) { const publishedAtFormatted = localizeDate(article.publishedAt); const body = `

${article.title}

User Avatar ${profile.name} ${publishedAtFormatted}

${article.html}
`; return htmlLayout(article.title, body, profile); } function articleListItemHtml(article: Article) { const formattedDate = localizeDate(article.publishedAt); return `

${article.title}

${formattedDate}

`; } export function articleListHtml(articles: Article[]) { if (articles.length === 0) return ""; let html = ""; for (const article of articles) { html += articleListItemHtml(article); } return `

Articles

${html}
`; } export function profilePageHtml(profile: Profile, articles: Article[]) { const title = `${profile.name} on Nostr`; const body = `
User Avatar

${profile.name}

${profile.about}

${articleListHtml(articles)}
`; return htmlLayout(title, body, profile); }