import { render as renderMarkdown } from "@deno/gfm";
import { log } from "./log.ts";
export function htmlLayout(title: string, body: string) {
return `
${title}
${body}
`;
}
export function articleHtml(articleEvent: object, profile: object) {
const titleTag = articleEvent.tags.find(t => t[0] === "title");
const title = titleTag ? titleTag[1] : "Untitled";
const content = renderMarkdown(articleEvent.content);
const date = new Date(articleEvent.created_at * 1000);
const formattedDate = date.toLocaleDateString("en-US", {
year: "numeric",
month: "long",
day: "numeric",
});
const body = `
${content}
`;
return htmlLayout(title, body);
}
export function profilePageHtml(profileEvent: object) {
const profile = JSON.parse(profileEvent.content);
const name = profile.name || "Anonymous";
const title = `${name} on Nostr`
// const date = new Date(articleEvent.created_at * 1000);
// const formattedDate = date.toLocaleDateString("en-US", {
// year: "numeric",
// month: "long",
// day: "numeric",
// });
const body = `
${profile.name}
${profile.about}
Articles
`;
return htmlLayout(title, body);
}