import { ImageResponse } from "next/og"; import { readFile } from "node:fs/promises"; import { join } from "node:path"; export { getPageTitle } from "@/lib/page-titles"; // Cache font data in memory after first load let fontCache: { geistRegular: Buffer; geistPixelSquare: Buffer } | null = null; async function loadFonts() { if (fontCache) return fontCache; const [geistRegular, geistPixelSquare] = await Promise.all([ readFile(join(process.cwd(), "public/Geist-Regular.ttf")), readFile(join(process.cwd(), "public/GeistPixel-Square.ttf")), ]); fontCache = { geistRegular, geistPixelSquare }; return fontCache; } export async function renderOgImage(title: string) { const { geistRegular, geistPixelSquare } = await loadFonts(); return new ImageResponse(