|
94 | 94 | mermaid.run(); |
95 | 95 | } |
96 | 96 |
|
| 97 | + // Intercept clicks on markdown links and convert to hash-based navigation |
| 98 | + this.interceptMarkdownLinks(content); |
| 99 | + |
97 | 100 | // Scroll to top |
98 | 101 | document.getElementById('content').scrollTop = 0; |
99 | 102 | } |
100 | 103 |
|
| 104 | + interceptMarkdownLinks(container) { |
| 105 | + // Find all links within the markdown content |
| 106 | + const links = container.querySelectorAll('a[href]'); |
| 107 | + |
| 108 | + links.forEach(link => { |
| 109 | + const href = link.getAttribute('href'); |
| 110 | + |
| 111 | + // Only intercept links to .md files (internal documentation links) |
| 112 | + if (href && href.endsWith('.md') && !href.startsWith('http://') && !href.startsWith('https://')) { |
| 113 | + link.addEventListener('click', (e) => { |
| 114 | + e.preventDefault(); |
| 115 | + |
| 116 | + // Remove leading './' or '/' if present |
| 117 | + let cleanPath = href.replace(/^\.\//, '').replace(/^\//, ''); |
| 118 | + |
| 119 | + // Update hash to trigger navigation |
| 120 | + window.location.hash = `/${cleanPath}`; |
| 121 | + }); |
| 122 | + } |
| 123 | + }); |
| 124 | + } |
| 125 | + |
101 | 126 | updateBreadcrumbs(path) { |
102 | 127 | const breadcrumbs = document.getElementById('breadcrumbs'); |
103 | 128 |
|
|
140 | 165 | link.textContent = formatModuleName(moduleName); |
141 | 166 | link.className = 'nav-link'; |
142 | 167 |
|
143 | | - // Active link highlighting is handled by updateActiveLink in the router |
144 | | - |
145 | 168 | item.appendChild(link); |
146 | 169 | container.appendChild(item); |
147 | 170 |
|
|
244 | 267 | const overviewLink = document.createElement('a'); |
245 | 268 | overviewLink.href = '#/'; |
246 | 269 | overviewLink.textContent = 'Overview'; |
247 | | - overviewLink.className = 'nav-link'; // Active state will be set by router |
| 270 | + overviewLink.className = 'nav-link'; |
248 | 271 | overviewItem.appendChild(overviewLink); |
249 | 272 | navTree.appendChild(overviewItem); |
250 | 273 |
|
|
0 commit comments