Motivation & Success Blog Post Generator

Motivation & Success Blog Post Generator

Craft an inspiring article to empower your audience in seconds.

${content}

`; }).join(''); post.conclusion = `Your journey towards ${data.postTopic.toLowerCase()} begins today. It starts with a single step, a single decision to demand more from yourself. Embrace these principles, commit to the process, and you will not only achieve your goals but become the person you were always meant to be. The future is yours to create.`; generatedPostHTML = `

${post.title}

${post.intro}

${post.body}

Your Journey Begins Now

${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('#fffbeb'); // amber-50 doc.rect(0, 0, pageWidth, 1.6, 'F'); // Decorative sun/mountain icon doc.setFillColor('#fcd34d'); // amber-300 doc.circle(margin + 0.3, 0.8, 0.3, 'F'); doc.setFillColor('#fbbf24'); // amber-400 doc.triangle(margin, 1.6, margin + 0.6, 1.6, margin + 0.3, 1.1, 'F'); doc.setFont('times', 'bold'); doc.setFontSize(22); doc.setTextColor('#78350f'); // amber-900 const titleText = tempDiv.querySelector('h2').innerText; const titleLines = doc.splitTextToSize(titleText, usableWidth - 1.5); doc.text(titleLines, margin + 1, 0.8); doc.setDrawColor('#d97706'); // amber-600 doc.setLineWidth(0.01); doc.line(margin, 1.6, pageWidth - margin, 1.6); currentY = 2; // Body Content doc.setFont('georgia', 'normal'); doc.setFontSize(11); doc.setTextColor('#374151'); // gray-700 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('georgia', 'bold'); doc.setFontSize(14); doc.setTextColor('#b45309'); // amber-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('Motivation-Success-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