fix: Fix docs-viewer TOC, cache busting, and documentLoaded event

- Fix TOC field name mismatch: API returns title/slug but renderTOC
  read text/id, causing empty bullet points
- Dispatch documentLoaded event after async content loads so sidebar
  TOC rebuilds with actual headings
- Update cache-bust version strings to force fresh JS/CSS

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
TheFlow 2026-02-09 10:36:18 +13:00
parent 1ed8ced02c
commit 962edaa34b
2 changed files with 16 additions and 10 deletions

View file

@ -4,8 +4,8 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Documentation - Tractatus Framework</title>
<link rel="stylesheet" href="/css/tailwind.css?v=0.1.2.1770452675442">
<link rel="stylesheet" href="/css/tractatus-theme.min.css?v=0.1.2.1770452675442">
<link rel="stylesheet" href="/css/tailwind.css?v=0.1.3.1739079900">
<link rel="stylesheet" href="/css/tractatus-theme.min.css?v=0.1.3.1739079900">
<style>
/* Prose styling for document content - uses plain CSS (not @apply, which is build-time only) */
.prose h1 { font-size: 1.875rem; font-weight: 700; margin-top: 2rem; margin-bottom: 1rem; color: #111827; line-height: 1.2; }
@ -77,12 +77,12 @@
</div>
<!-- Scripts -->
<script src="/js/utils/api.js?v=0.1.2.1770452675442"></script>
<script src="/js/utils/router.js?v=0.1.2.1770452675442"></script>
<script src="/js/components/document-viewer.js?v=0.1.2.1770452675442"></script>
<script src="/js/components/code-copy-button.js?v=0.1.2.1770452675442"></script>
<script src="/js/components/toc.js?v=0.1.2.1770452675442"></script>
<script src="/js/docs-viewer-app.js?v=0.1.2.1770452675442"></script>
<script src="/js/utils/api.js?v=0.1.3.1739079900"></script>
<script src="/js/utils/router.js?v=0.1.3.1739079900"></script>
<script src="/js/components/document-viewer.js?v=0.1.3.1739079900"></script>
<script src="/js/components/code-copy-button.js?v=0.1.3.1739079900"></script>
<script src="/js/components/toc.js?v=0.1.3.1739079900"></script>
<script src="/js/docs-viewer-app.js?v=0.1.3.1739079900"></script>
</body>
</html>

View file

@ -92,6 +92,9 @@ class DocumentViewer {
// Add smooth scroll to TOC links
this.initializeTOCLinks();
// Notify TOC component that content has loaded
document.dispatchEvent(new Event('documentLoaded'));
}
/**
@ -110,11 +113,14 @@ class DocumentViewer {
item.level === 3 ? 'ml-8' :
item.level === 4 ? 'ml-12' :
'ml-16';
// Handle both API formats: {text, id} and {title, slug}
const itemText = item.text || item.title || '';
const itemId = item.id || item.slug || '';
return `
<li class="${marginClass}">
<a href="#${item.id}"
<a href="#${itemId}"
class="text-blue-600 hover:text-blue-700 hover:underline">
${this.escapeHtml(item.text)}
${this.escapeHtml(itemText)}
</a>
</li>
`;