Skip to content

Commit cf06340

Browse files
committed
adjust docs UI
1 parent 33f1537 commit cf06340

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

  • codewiki/templates/github_pages

codewiki/templates/github_pages/app.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,35 @@
9494
mermaid.run();
9595
}
9696

97+
// Intercept clicks on markdown links and convert to hash-based navigation
98+
this.interceptMarkdownLinks(content);
99+
97100
// Scroll to top
98101
document.getElementById('content').scrollTop = 0;
99102
}
100103

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+
101126
updateBreadcrumbs(path) {
102127
const breadcrumbs = document.getElementById('breadcrumbs');
103128

@@ -140,8 +165,6 @@
140165
link.textContent = formatModuleName(moduleName);
141166
link.className = 'nav-link';
142167

143-
// Active link highlighting is handled by updateActiveLink in the router
144-
145168
item.appendChild(link);
146169
container.appendChild(item);
147170

@@ -244,7 +267,7 @@
244267
const overviewLink = document.createElement('a');
245268
overviewLink.href = '#/';
246269
overviewLink.textContent = 'Overview';
247-
overviewLink.className = 'nav-link'; // Active state will be set by router
270+
overviewLink.className = 'nav-link';
248271
overviewItem.appendChild(overviewLink);
249272
navTree.appendChild(overviewItem);
250273

0 commit comments

Comments
 (0)