const fs = require('fs'); const path = require('path'); const { renderHtml, shutdownPool } = require('./browserPool'); async function generateQuote(config, outputPath = 'quote.png') { const htmlTemplate = fs.readFileSync(path.join(__dirname, 'quote.html'), 'utf8'); const configScript = ` `; const modifiedHtml = htmlTemplate.replace('', `${configScript}`); const imageBuffer = await renderHtml(modifiedHtml, 500); fs.writeFileSync(outputPath, imageBuffer); console.log(`Quote generated: ${outputPath}`); } // Example usage const exampleTweet = { displayName: "Geoff Marshall", username: "@geofftech", avatarUrl: "https://pbs.twimg.com/profile_images/1295490618140110848/Fu4chISB_x96.jpg", text: "Does anyone else find it immensely satisfying when you turn a pocket inside out and get rid of the crumbs and fluff stuck in the bottom.", imageUrl: null, timestamp: "10:04 AM · Jul 11, 2017", viewsCount: "128K" }; const exampleTweetWithImage = { displayName: "miss katie", username: "@katiopolis", avatarUrl: "https://pbs.twimg.com/profile_images/2004569144893554688/KaYjqylC_x96.jpg", text: "omg i brought these watches home because none of them worked but i thought id hang onto them and my dad fixed and polished them all for me 😭 i love him so much", imageUrl: "https://pbs.twimg.com/media/G9Wtk1xWcAA-WMZ?format=jpg&name=large", timestamp: "5:58 PM · Dec 29, 2025", viewsCount: "1.1M" }; // Generate both examples (async () => { await generateQuote(exampleTweet, 'quote-no-image.png'); await generateQuote(exampleTweetWithImage, 'quote-with-image.png'); await shutdownPool(); })(); module.exports = { generateQuote };