import Mustache from "mustache"; import { BlogPost, getPost, getPosts } from "../../models/blog.js"; async function getFile(file: string) { return Bun.file(`src/views/admin/${file}.html`, { type: "text/html;charset=utf-8", }).text(); } export async function RenderForm(domain: string) { const postHtml = await getFile("main"); return Mustache.render(postHtml, { domain: domain, footer: "xero harrison", content: "

hi!

", }); } export async function RenderEditForm(post:any, domain: string) { const postHtml = await getFile("edit_post"); const postData = getPost(post); return Mustache.render(postHtml, { url: postData[0].url, date: new Date(postData[0].date*1000).toLocaleDateString("en-CA", { timeZone: "America/New_York"}), title: postData[0].title, subtitle: postData[0].subtitle, excerpt: postData[0].excerpt, content: postData[0].content, domain: domain, footer: "xero harrison", }); } export async function RenderEdit(hx: boolean, domain: string) { const blogPosts: BlogPost = getPosts(1000, 0); let list: string = ''; blogPosts.forEach((post:any) => { list += `