Skip to content

Commit 9ade6b6

Browse files
committed
docs: compact help topics with accordions
1 parent 5b75bde commit 9ade6b6

4 files changed

Lines changed: 177 additions & 99 deletions

File tree

scripts/test-website-theme.mjs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,32 @@ for (const metadata of requiredHelpMetadata) {
132132
throw new Error(`help.html is missing SEO/AEO metadata: ${metadata}`);
133133
}
134134
}
135+
const helpStructuredDataMatch = helpPage.match(/<script type="application\/ld\+json">([\s\S]*?)<\/script>/);
136+
if (!helpStructuredDataMatch) {
137+
throw new Error('help.html must contain JSON-LD structured data');
138+
}
139+
const helpStructuredData = JSON.parse(helpStructuredDataMatch[1]);
140+
const helpFaqPage = helpStructuredData['@graph'].find(item => (
141+
Array.isArray(item['@type']) && item['@type'].includes('FAQPage')
142+
));
143+
const helpVisibleText = helpPage
144+
.replace(/<script[\s\S]*?<\/script>/g, ' ')
145+
.replace(/<[^>]+>/g, '')
146+
.replaceAll('&amp;', '&')
147+
.replaceAll('&quot;', '"')
148+
.replaceAll('&#39;', "'")
149+
.replaceAll('&lt;', '<')
150+
.replaceAll('&gt;', '>')
151+
.replaceAll('&nbsp;', ' ')
152+
.replace(/\s+/g, ' ');
153+
for (const question of helpFaqPage?.mainEntity || []) {
154+
if (!helpVisibleText.includes(question.name) || !helpVisibleText.includes(question.acceptedAnswer?.text)) {
155+
throw new Error(`help.html FAQ content must be visible and exact: ${question.name}`);
156+
}
157+
}
158+
if ((helpPage.match(/class="support-card support-anchor-section support-accordion"/g) || []).length < 10) {
159+
throw new Error('help.html must keep advanced and troubleshooting sections compact with native accordions');
160+
}
135161
if (!llmsText.includes('[Help Center](https://sync.koalastuff.net/help)')
136162
|| !llmsText.includes('[Website access guide](https://sync.koalastuff.net/site-access-help)')) {
137163
throw new Error('llms.txt must expose the Help Center and website-access guide');

website/app.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,6 +1760,20 @@ document.addEventListener('DOMContentLoaded', () => {
17601760
updateDynamicVersion();
17611761
localizeHomeLinks();
17621762
initLanguageSelectorValue();
1763+
const openSupportAccordion = hash => {
1764+
if (!hash || hash === '#') return;
1765+
const target = document.getElementById(decodeURIComponent(hash.slice(1)));
1766+
if (target?.matches('details.support-accordion')) {
1767+
target.open = true;
1768+
window.requestAnimationFrame(() => target.scrollIntoView({ block: 'start' }));
1769+
}
1770+
};
1771+
openSupportAccordion(window.location.hash);
1772+
window.addEventListener('hashchange', () => openSupportAccordion(window.location.hash));
1773+
document.addEventListener('click', event => {
1774+
const link = event.target.closest('a[href^="#"]');
1775+
if (link) openSupportAccordion(link.hash);
1776+
});
17631777
if (document.fonts?.ready) {
17641778
document.fonts.ready.then(adjustDropdownWidth);
17651779
}

0 commit comments

Comments
 (0)