import { promises as fs } from "fs"; import path from "path"; import hljs from "highlight.js"; import ejs from "ejs"; import formatDate from "date-fns/format"; export async function write(filePath: string, data: any) { const dest = path.join("out", filePath); await fs.mkdir(path.dirname(dest), { recursive: true }); await fs.writeFile(dest, data); } export function getReadingTime(text: string): number { const avgWPM = 225; const words = text.split(/\s+/).length; return Math.max(1, Math.round(words / avgWPM)) } export function highlight(source: string, language?: string): string { const res = language ? hljs.highlight(language, source) : hljs.highlightAuto(source); const highlighted = res.value; return `
${highlighted}
`;
}
interface Chunk