Gaming Blog Post Generator

Gaming Blog Post Generator

Create an epic first draft of your game review or feature.

${post.conclusion}

`; elements.outputContainer.innerHTML = generatedPostHTML; }; const handleDownloadPdf = () => { const { jsPDF } = window.jspdf; if (!jsPDF) { console.error("jsPDF is not loaded."); return; } const doc = new jsPDF({ orientation: 'portrait', unit: 'in', format: 'letter' }); const tempDiv = document.createElement('div'); tempDiv.innerHTML = generatedPostHTML; const margin = 0.75; const pageWidth = doc.internal.pageSize.getWidth(); const usableWidth = pageWidth - (margin * 2); let currentY = 0; // PDF Header doc.setFillColor('#111827'); // gray-900 doc.rect(0, 0, pageWidth, 2, 'F'); // Decorative controller icon doc.setDrawColor('#22d3ee'); // cyan-400 doc.setLineWidth(0.015); // D-pad doc.rect(margin + 0.1, 1.25, 0.2, 0.05); doc.rect(margin + 0.175, 1.175, 0.05, 0.2); // Body doc.roundedRect(margin, 0.7, 1.5, 0.8, 0.2, 0.2); doc.setFont('helvetica', 'bold'); doc.setFontSize(24); doc.setTextColor('#f9fafb'); // gray-50 const titleText = tempDiv.querySelector('h2').innerText; const titleLines = doc.splitTextToSize(titleText, usableWidth - 2); doc.text(titleLines, margin + 1.7, 1); currentY = 2.2; // Body Content doc.setFont('georgia', 'normal'); doc.setFontSize(11); doc.setTextColor('#1f2937'); // gray-800 doc.setLineHeightFactor(1.6); Array.from(tempDiv.children).forEach(el => { if (el.tagName === 'H2') return; // Skip title if (currentY > 10) { doc.addPage(); currentY = margin; } let text = el.innerText || el.textContent || ''; if (el.tagName === 'H3') { currentY += 0.2; doc.setFont('helvetica', 'bold'); doc.setFontSize(14); doc.setTextColor('#0e7490'); // cyan-700 doc.text(text, margin, currentY); doc.setFont('georgia', 'normal'); doc.setFontSize(11); currentY += 0.35; } else if (el.tagName === 'P') { const pLines = doc.splitTextToSize(text, usableWidth); doc.text(pLines, margin, currentY); currentY += (pLines.length * 0.25); } }); doc.save('Gaming-Blog-Post.pdf'); }; // --- Event Listeners --- elements.tabDefine.addEventListener('click', () => switchTab('define')); elements.tabReview.addEventListener('click', () => switchTab('review')); elements.nextBtn.addEventListener('click', () => currentTab === 'define' && switchTab('review')); elements.prevBtn.addEventListener('click', () => currentTab === 'review' && switchTab('define')); elements.downloadPdfBtn.addEventListener('click', handleDownloadPdf); });
Scroll to Top