Skip to content

Commit 7497188

Browse files
committed
better fix for release switcher
1 parent 538b1d1 commit 7497188

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

docs/.vitepress/config.mts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,19 @@ document.addEventListener('click', (e) => {
9191
const link = e.target.closest('a');
9292
if (!link) return;
9393
const href = link.getAttribute('href');
94-
// Check if this is a version switch link (contains /release/ or is ../)
95-
if (href && (href.includes('/release/') || href === '../' || href.endsWith('/release/'))) {
94+
// Check if this is a version switch link
95+
if (href && (href.includes('/release/') || href === '../')) {
9696
e.preventDefault();
9797
e.stopPropagation();
98-
window.location.href = link.href;
98+
if (href === '../') {
99+
// Navigate from /release/ back to main - construct path explicitly
100+
// to avoid relative path issues with trailing slashes
101+
const path = window.location.pathname;
102+
const mainPath = path.replace(/\\/release\\/.*$/, '/').replace(/\\/release$/, '/');
103+
window.location.href = mainPath;
104+
} else {
105+
window.location.href = link.href;
106+
}
99107
}
100108
}, true);
101109
`;

0 commit comments

Comments
 (0)