Social Issues Blog Post Generator

Social Issues Blog Post Generator

Craft thoughtful and impactful articles on important topics.

Article Foundation

Background & Context

Key Arguments & Evidence

Conclusion & Call to Action

Generated Article

Copied to clipboard!

${item.description}

`; }); } preview.innerHTML = `

${data.title}

An analysis of ${data.issue}

Introduction

${data.introduction}

${data.thesis}

Background

${data.background}

Key Arguments

${argumentsHtml}

Conclusion

${data.conclusion}

Call to Action

${data.cta}

`; } function showMessage() { messageBox.classList.remove('opacity-0', 'translate-y-10'); messageBox.classList.add('opacity-100', 'translate-y-0'); setTimeout(() => { messageBox.classList.remove('opacity-100', 'translate-y-0'); messageBox.classList.add('opacity-0', 'translate-y-10'); }, 2000); } function generateSocialIssuesPdf() { const { jsPDF } = window.jspdf; const pdf = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' }); const data = getFormData(); const pageW = pdf.internal.pageSize.getWidth(); const pageH = pdf.internal.pageSize.getHeight(); const margin = 20; const contentWidth = pageW - (margin * 2); let y = 0; const lineH = 7; const addHeaderFooter = () => { const pageCount = pdf.internal.getNumberOfPages(); for (let i = 1; i <= pageCount; i++) { pdf.setPage(i); pdf.setFontSize(9); pdf.setTextColor('#94a3b8'); // slate-400 if (i > 1) { pdf.text(data.title, margin, 12); } pdf.text(`Page ${i}`, pageW - margin, pageH - 10, { align: 'right' }); } }; const checkBreak = (needed = 20) => { if (y + needed > pageH - margin) { pdf.addPage(); y = margin; } }; const addText = (text, options = {}) => { const { size=11, style='normal', color='#334155', indent=0, spacing=1 } = options; if (!text && text !== '') return; checkBreak(15); pdf.setFontSize(size); pdf.setFont('times', style); pdf.setTextColor(color); const splitText = pdf.splitTextToSize(text, contentWidth - indent); pdf.text(splitText, margin + indent, y); y += (splitText.length * lineH * 0.75) + (lineH * spacing); }; const addSectionHeader = (title) => { y += lineH * 1.5; checkBreak(20); pdf.setFontSize(16); pdf.setFont('helvetica', 'bold'); pdf.setTextColor('#1d4ed8'); // blue-700 pdf.text(title, margin, y); y += lineH * 1.5; }; // --- Build PDF Document --- // Page 1: Title Page pdf.setFillColor('#1e293b'); // slate-800 pdf.rect(0, 0, pageW, pageH, 'F'); pdf.setFontSize(32); pdf.setFont('helvetica', 'bold'); pdf.setTextColor('#f8fafc'); // slate-50 const titleLines = pdf.splitTextToSize(data.title, contentWidth - 20); pdf.text(titleLines, pageW / 2, 120, { align: 'center' }); pdf.setFontSize(14); pdf.setFont('helvetica', 'normal'); pdf.setTextColor('#94a3b8'); // slate-400 pdf.text(`An analysis of ${data.issue}`, pageW / 2, 135 + (titleLines.length * 12), { align: 'center' }); pdf.addPage(); y = margin; // Introduction addSectionHeader("Introduction"); addText(data.introduction); if(data.thesis) { y += lineH; addText(`"${data.thesis}"`, {style: 'italic', size: 12, color: '#475569', indent: 5}); y += lineH; } // Background addSectionHeader("Background"); addText(data.background); // Arguments if (data.arguments.length > 0) { addSectionHeader("Key Arguments"); data.arguments.forEach((item) => { checkBreak(30); addText(item.title, { style: 'bold', size: 14, color: '#1e293b', spacing: 0.5 }); addText(item.description, {spacing: 1.5, indent: 5}); }); } // Conclusion addSectionHeader("Conclusion"); addText(data.conclusion); // CTA if(data.cta) { addSectionHeader("Call to Action"); addText(data.cta); } addHeaderFooter(); pdf.save(`Social_Issue_${data.title.replace(/\s+/g, '_').substring(0,20)}.pdf`); } // --- Event Listeners & Init --- tabs.forEach(tab => tab.addEventListener('click', () => goToTab(parseInt(tab.dataset.tab)))); prevButton.addEventListener('click', () => goToTab(currentTab - 1)); nextButton.addEventListener('click', () => goToTab(currentTab + 1)); copyButton.addEventListener('click', () => { const preview = document.getElementById('report-preview-container'); if (preview) { navigator.clipboard.writeText(preview.innerText).then(() => { showMessage(); }).catch(err => console.error('Copy failed: ', err)); } }); pdfDownloadButton.addEventListener('click', generateSocialIssuesPdf); addArgumentButton.addEventListener('click', addArgumentItem); // Add one initial argument item addArgumentItem(); updateTabUI(); });
Scroll to Top