Trending Topic Analyzer

Trending Topic Analyzer

Break down any topic into a strategic content plan.

Core Subject

Topic Breakdown (The 5 W's and 1 H)

Content Strategy

Generated Topic Analysis

Copied to clipboard!

Content Goal: ${data.goal}

Topic Breakdown (5W1H)

${data.who ? `

Who?

${data.who}

` : ''} ${data.what ? `

What?

${data.what}

` : ''} ${data.where ? `

Where?

${data.where}

` : ''} ${data.when ? `

When?

${data.when}

` : ''} ${data.why ? `

Why?

${data.why}

` : ''} ${data.how ? `

How?

${data.how}

` : ''}

Content Strategy

Keywords

${listToHtml(data.keywords)}

Content Angles

${listToHtml(data.angles)} `; } 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 generateAnalysisPdf() { 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 = 6; const today = new Date().toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }); const addHeaderFooter = () => { const pageCount = pdf.internal.getNumberOfPages(); for (let i = 1; i <= pageCount; i++) { pdf.setPage(i); // Add header to all pages except the first one if (i > 1) { pdf.setFontSize(9); pdf.setTextColor('#6b7280'); pdf.text('Topic Analysis Report', margin, 12); pdf.text(data.topic, pageW - margin, 12, { align: 'right' }); pdf.setDrawColor('#d1d5db'); pdf.setLineWidth(0.2); pdf.line(margin, 15, pageW - margin, 15); } // Add footer to all pages pdf.setFontSize(8); pdf.setTextColor('#6b7280'); pdf.text(`Page ${i} of ${pageCount}`, pageW / 2, pageH - 10, { align: 'center' }); } }; const checkBreak = (needed = 20) => { if (y + needed > pageH - margin) { pdf.addPage(); y = margin + 10; } }; const addText = (text, options = {}) => { const { size=10, style='normal', color='#374151', indent=0, spacing=1 } = options; if (!text) return; checkBreak(); pdf.setFontSize(size); pdf.setFont(undefined, style); pdf.setTextColor(color); const splitText = pdf.splitTextToSize(text, contentWidth - indent); pdf.text(splitText, margin + indent, y); y += (splitText.length * lineH * 0.8) + (lineH * spacing); }; const addSectionHeader = (title) => { y += lineH * 2; checkBreak(20); pdf.setFontSize(14); pdf.setFont(undefined, 'bold'); pdf.setTextColor('#0f766e'); // teal-700 pdf.text(title, margin, y); y += lineH * 1.5; pdf.setDrawColor('#5eead4'); // teal-300 pdf.setLineWidth(0.5); pdf.line(margin, y - (lineH*0.8), margin + 40, y - (lineH*0.8)); }; // --- Build PDF Document --- // Page 1: Title Page pdf.setFillColor('#f0fdfa'); // teal-50 pdf.rect(0, 0, pageW, pageH, 'F'); pdf.setFillColor('#134e4a'); // teal-900 pdf.rect(0, 0, pageW, 60, 'F'); pdf.setFontSize(28); pdf.setFont(undefined, 'bold'); pdf.setTextColor('#FFFFFF'); pdf.text('Topic Analysis Report', pageW / 2, 35, { align: 'center' }); pdf.setFontSize(18); pdf.setTextColor('#1f2937'); pdf.text(data.topic, pageW / 2, 100, { align: 'center' }); pdf.setFontSize(11); pdf.setTextColor('#4b5563'); pdf.text(`Generated on ${today}`, pageW / 2, 120, { align: 'center' }); // New Page for Content pdf.addPage(); y = margin + 10; // Core Subject Section addSectionHeader("Core Subject"); addText('Target Audience:', {style: 'bold'}); addText(data.audience); y += lineH; addText('Content Goal:', {style: 'bold'}); addText(data.goal); // 5W1H Section addSectionHeader("Topic Breakdown (5W1H)"); const breakdown = { Who: data.who, What: data.what, Where: data.where, When: data.when, Why: data.why, How: data.how }; for(const [key, value] of Object.entries(breakdown)) { if (value) { addText(`${key}?`, { style: 'bold', size: 11, color: '#115e59' }); addText(value, { indent: 4 }); y += lineH * 0.5; } } // Strategy Section addSectionHeader("Content Strategy"); if (data.keywords.length > 0) { addText('Keywords', { style: 'bold', size: 11, color: '#115e59' }); data.keywords.forEach(kw => addText(`• ${kw.replace(/^- /, '')}`, { indent: 4 })); y += lineH; } if (data.angles.length > 0) { addText('Content Angles / Titles', { style: 'bold', size: 11, color: '#115e59' }); data.angles.forEach(angle => addText(`• ${angle.replace(/^- /, '')}`, { indent: 4 })); } addHeaderFooter(); pdf.save(`Topic_Analysis_${data.topic.replace(/\s+/g, '_')}.pdf`); } // --- Event Listeners --- 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', generateAnalysisPdf); // Initialize updateTabUI(); });
Scroll to Top