Opening answer paragraph — paste at top of page
${c.answerParagraph || ''}
Voice-search optimized H2 headings
${headings}
AEO body copy
${c.introSection || ''}
FAQ section — add to bottom of page + matches schema
${faqs}
`;
outputArea.appendChild(contentCard);
}
}
// Gap card
if (doGap && results.gap) {
const g = safeJSON(results.gap);
if (g) {
const gapCard = document.createElement('div');
gapCard.className = 'result-card';
gapCard.innerHTML = `
${g.quickWins ? `
Quick wins — add these now
${g.quickWins.map(w => `
`).join('')}
` : ''}
Missing questions to answer on this page
${(g.missingQuestions||[]).map((q,i) => `
`).join('')}
${g.contentGaps ? `
Topic areas needing dedicated sections
${g.contentGaps.map(gap => `
`).join('')}` : ''}
`;
outputArea.appendChild(gapCard);
}
}
// Implementation guide
const guideCard = document.createElement('div');
guideCard.className = 'result-card';
guideCard.innerHTML = `
Files to update
${[
['app/' + url.replace(/^\//, '') + '/page.tsx', 'Add answer paragraph + FAQ section + H2 headings'],
['app/layout.tsx or page.tsx head', 'Add JSON-LD schema in <script> tag'],
['app/sitemap.ts', 'Confirm page URL is listed ✓'],
['app/robots.ts', 'Already configured ✓'],
].map(([file, desc]) => `
`).join('')}
`;
outputArea.appendChild(guideCard);
}
function switchTab(btn, panelId) {
btn.closest('.result-body').querySelectorAll('.tab-btn').forEach(b => b.classList.remove('active'));
btn.closest('.result-body').querySelectorAll('.tab-panel').forEach(p => p.classList.remove('active'));
btn.classList.add('active');
document.getElementById(panelId).classList.add('active');
}
function formatJSON(raw) {
try {
const clean = raw.replace(/```json\n?/g,'').replace(/```\n?/g,'').trim();
const obj = JSON.parse(clean);
return escHtml(JSON.stringify(obj, null, 2));
} catch(e) {
return escHtml(raw);
}
}
function escHtml(str) {
return str.replace(/&/g,'&').replace(//g,'>');
}
function copyText(id) {
const el = document.getElementById(id);
const text = el.innerText;
navigator.clipboard.writeText(text).then(() => {
const btn = el.closest('.result-card').querySelector('.copy-btn');
btn.textContent = 'Copied!';
setTimeout(() => btn.textContent = 'Copy', 1500);
});
}
function copyAllContent() {
const panels = ['tab-answer','tab-headings','tab-body','tab-faq','tab-meta'];
let all = '';
panels.forEach(id => {
const el = document.getElementById(id);
if (el) all += el.innerText + '\n\n---\n\n';
});
navigator.clipboard.writeText(all).then(() => {
const btns = document.querySelectorAll('.copy-btn');
btns.forEach(b => { if(b.textContent === 'Copy all') { b.textContent = 'Copied!'; setTimeout(()=>b.textContent='Copy all',1500); }});
});
}