Skip to content

Commit da2cf0a

Browse files
jdxJeff Dickey
andauthored
fix(docs): route tool search results to mise-versions (#12097)
Co-authored-by: Jeff Dickey <jdx@pro.wallaby-spica.ts.net>
1 parent f669017 commit da2cf0a

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

docs/.vitepress/theme/index.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,27 @@ import { data as starsData } from "../stars.data";
1111
export default {
1212
extends: DefaultTheme,
1313
Layout,
14-
enhanceApp({ app }) {
14+
enhanceApp({ app, router }) {
1515
enhanceAppWithTabs(app);
1616
initBanner();
17+
18+
const onBeforeRouteChange = router.onBeforeRouteChange;
19+
router.onBeforeRouteChange = async (to) => {
20+
if (typeof window !== "undefined") {
21+
const url = new URL(to, window.location.origin);
22+
if (
23+
url.origin === window.location.origin &&
24+
url.pathname.startsWith("/tools/")
25+
) {
26+
const toolPath = url.pathname.replace(/\.html$/, "");
27+
window.location.assign(
28+
`https://mise-versions.jdx.dev${toolPath}${url.search}${url.hash}`,
29+
);
30+
return false;
31+
}
32+
}
33+
return onBeforeRouteChange?.(to);
34+
};
1735
},
1836
setup() {
1937
onMounted(() => {

0 commit comments

Comments
 (0)