the home site for me: also iteration 3 or 4 of my site
1import puppeteer from "puppeteer"; 2 3const template = await Bun.file("tools/og.html").text(); 4 5const browser = await puppeteer.launch(); 6 7async function og( 8 postname: string, 9 outputPath: string, 10 width = 1200, 11 height = 630 12) { 13 const page = await browser.newPage(); 14 15 await page.setViewport({ width, height }); 16 17 await page.setContent(template.toString().replace("{{postname}}", postname)); 18 19 await page.screenshot({ path: outputPath }); 20} 21 22try { 23 await og("an early tale of tomfoolery", "og.png"); 24} catch (e) { 25 console.error(e); 26} finally { 27 await browser.close(); 28}