Social Media Post Generator

Social Media Post Generator

Create engaging posts for your social channels in seconds with AI.

Post Details

Generated Posts

Your generated social media posts will appear here.

${post}

`; dom.output.innerHTML += postCard; }); dom.output.classList.remove('hidden'); dom.downloadBtn.classList.remove('hidden'); lucide.createIcons(); dom.output.querySelectorAll('.copy-post-btn').forEach(btn => { btn.addEventListener('click', (e) => copyText(posts[e.currentTarget.dataset.index], e.currentTarget)); }); } function copyText(text, button) { navigator.clipboard.writeText(text).then(() => { const originalHTML = button.innerHTML; button.innerHTML = 'Copied!'; button.disabled = true; setTimeout(() => { button.innerHTML = originalHTML; button.disabled = false; lucide.createIcons(); }, 1500); }).catch(err => console.error('Failed to copy text: ', err)); } function downloadPDF() { const { jsPDF } = window.jspdf; const posts = Array.from(dom.output.querySelectorAll('.post-text')).map(el => el.textContent); if (posts.length === 0) return; const pdf = new jsPDF({ orientation: 'p', unit: 'pt', format: 'a4' }); const pageMargin = 40; const pdfWidth = pdf.internal.pageSize.getWidth(); const contentWidth = pdfWidth - (pageMargin * 2); pdf.setFont('Inter', 'bold'); pdf.setFontSize(18); pdf.text('Generated Social Media Posts', pdfWidth / 2, pageMargin, { align: 'center' }); pdf.setFontSize(11); let yPos = pageMargin + 40; posts.forEach((post, index) => { pdf.setFont('Inter', 'bold'); pdf.text(`Option ${index + 1}:`, pageMargin, yPos); yPos += 15; pdf.setFont('Inter', 'normal'); const lines = pdf.splitTextToSize(post, contentWidth); pdf.text(lines, pageMargin, yPos); yPos += (lines.length * 12) + 20; // 12pt font size, plus spacing }); pdf.save('Social_Media_Posts.pdf'); } init(); });
Scroll to Top