Self-Improvement Blog Post Generator

Self-Improvement Blog Post Generator

Craft inspiring and actionable content for personal growth.

Why is ${topic.toLowerCase()} so challenging? Often, we're held back by self-doubt, old patterns, or simply not knowing where to start. For example, the fear of failure can be paralyzing. Recognizing these internal and external obstacles is the first crucial step toward overcoming them and moving forward with clarity.

`, Actions: (topic) => `

Actionable Steps to Begin Today

Theory is valuable, but action creates real change. Here are three practical steps you can take today to begin your journey of ${topic.toLowerCase()}:

  • Start Small: Identify one small, manageable action you can take. If your goal is building confidence, this could be speaking up once in a meeting.
  • Track Your Progress: Keep a journal to note your efforts and small wins. This builds momentum and provides tangible evidence of your growth.
  • Practice Self-Compassion: You will face setbacks. Instead of self-criticism, treat yourself with the same kindness you would offer a friend.
`, Mindset: (topic) => `

The All-Important Mindset Shift

The biggest changes start from within. To truly succeed in ${topic.toLowerCase()}, you need to cultivate a growth mindset. Instead of thinking, "I'm not good at this," try reframing it as, "I'm learning and growing with every attempt." This subtle shift in perspective can make all the difference in your journey.

`, Quote: (topic) => `

An Inspiring Thought

"The only person you are destined to become is the person you decide to be." – Ralph Waldo Emerson

`, Conclusion: (topic) => `

Your Path Forward

Your journey with ${topic.toLowerCase()} is unique and ongoing. Remember to be patient and celebrate your progress, no matter how small. Every step forward is a victory. You have the power within you to create the positive change you seek and build a more fulfilling life.

` }; const generatePost = () => { const topic = topicInput.value.trim(); const audience = audienceInput.value.trim(); const selectedSections = Array.from(document.querySelectorAll('#sections-container input:checked')).map(cb => cb.value); if (!topic) { postContainer.innerHTML = '

Please enter a topic for the blog post.

'; return; } let postHTML = `

Your Guide to ${topic}

`; selectedSections.forEach(key => { if (sectionTemplates[key]) { postHTML += sectionTemplates[key](topic, audience); } }); postContainer.innerHTML = postHTML; outputTitle.textContent = `Generated Post: ${topic}`; downloadPdfBtn.classList.remove('hidden'); }; const downloadPdf = () => { const { jsPDF } = window.jspdf; const doc = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' }); const content = getEl('generated-post-container'); const title = `Your Guide to ${topicInput.value.trim()}`; const pageWidth = doc.internal.pageSize.getWidth(); const margin = 15; // --- PDF Template: Self-Improvement Guide --- // Header with gradient const grad = doc.context2d.createLinearGradient(0, 0, pageWidth, 0); grad.addColorStop(0, '#8b5cf6'); // Violet-500 grad.addColorStop(1, '#c084fc'); // Purple-400 doc.context2d.fillStyle = grad; doc.rect(0, 0, pageWidth, 28, 'F'); doc.setFont('helvetica', 'bold'); doc.setFontSize(18); doc.setTextColor(255, 255, 255); const splitTitle = doc.splitTextToSize(title, pageWidth - (margin * 2)); doc.text(splitTitle, margin, 18); html2canvas(content, { scale: 2, useCORS: true, windowWidth: content.scrollWidth, windowHeight: content.scrollHeight }).then(canvas => { const imgData = canvas.toDataURL('image/png'); const imgProps = doc.getImageProperties(imgData); const pdfWidth = pageWidth - (margin * 2); const pdfHeight = (imgProps.height * pdfWidth) / imgProps.width; let heightLeft = pdfHeight; let position = 40; // Start content below header doc.addImage(imgData, 'PNG', margin, position, pdfWidth, pdfHeight, undefined, 'FAST'); heightLeft -= (doc.internal.pageSize.getHeight() - position - margin); while (heightLeft >= 0) { position = heightLeft - pdfHeight; doc.addPage(); doc.addImage(imgData, 'PNG', margin, position, pdfWidth, pdfHeight, undefined, 'FAST'); heightLeft -= doc.internal.pageSize.getHeight(); } // Footer on all pages const pageCount = doc.internal.getNumberOfPages(); for(let i = 1; i <= pageCount; i++) { doc.setPage(i); doc.setFontSize(8); doc.setTextColor(107, 114, 128); doc.text( `Generated by the Self-Improvement Blog Post Generator`, margin, 287 ); doc.text( `Page ${i} of ${pageCount}`, pageWidth - margin, 287, { align: 'right' } ); } doc.save(`Self_Improvement_${topicInput.value.trim().replace(/\s/g, '_')}.pdf`); }).catch(err => { console.error("Error generating PDF:", err); alert("Could not generate PDF. See console for details."); }); }; const showTab = (tabNum) => { currentTab = tabNum; tabButtons.forEach(btn => btn.classList.toggle('active', parseInt(btn.dataset.tab) === tabNum)); tabPanes.forEach(pane => pane.classList.toggle('hidden', parseInt(pane.id.split('-')[2]) !== tabNum)); prevBtn.classList.toggle('invisible', currentTab === 1); nextBtn.textContent = currentTab === 1 ? 'Generate Post' : 'Generate Again'; }; // --- Event Listeners --- tabButtons.forEach(button => { button.addEventListener('click', () => { const tabNum = parseInt(button.dataset.tab); if (tabNum === 2 && currentTab === 1) generatePost(); showTab(tabNum); }); }); prevBtn.addEventListener('click', () => { if (currentTab > 1) showTab(currentTab - 1) }); nextBtn.addEventListener('click', () => { if (currentTab === 1) { generatePost(); showTab(2); } else { generatePost(); } }); downloadPdfBtn.addEventListener('click', downloadPdf); // --- Initial Setup --- showTab(1); });
Scroll to Top