| // Document Hub — render the route manifest as clickable routing cards. | |
| async function init() { | |
| let manifest; | |
| try { manifest = await fetch('/api/routes').then(r => r.json()); } | |
| catch (_) { document.getElementById('manifest').innerHTML = '<p>manifest unavailable</p>'; return; } | |
| const host = document.getElementById('manifest'); | |
| host.innerHTML = ''; | |
| manifest.groups.forEach(g => { | |
| const title = document.createElement('div'); | |
| title.className = 'group-title'; | |
| title.textContent = g.group; | |
| host.appendChild(title); | |
| const grid = document.createElement('div'); | |
| grid.className = 'routegrid'; | |
| g.routes.forEach(r => { | |
| // GET (and pages/external) are clickable; templated/POST render as static cards. | |
| const clickable = (r.kind === 'get' || r.kind === 'page' || r.kind === 'external'); | |
| const tag = clickable ? 'a' : 'div'; | |
| const card = document.createElement(tag); | |
| card.className = 'routecard' + (r.method === 'POST' ? ' post' : '') + (r.kind === 'external' ? ' external' : ''); | |
| if (clickable) { card.href = r.path; if (r.kind !== 'page') card.target = '_blank'; } | |
| const shown = r.kind === 'external' ? r.path.replace(/^https?:\/\//, '') : r.path; | |
| card.innerHTML = `<span class="m">${r.method}</span> | |
| <div class="lbl">${r.label}${clickable ? ' ↗' : ''}</div> | |
| <div class="path">${shown}</div> | |
| <div class="d">${r.desc}</div>`; | |
| grid.appendChild(card); | |
| }); | |
| host.appendChild(grid); | |
| }); | |
| } | |
| init(); | |