~ruther/qmk_firmware

ref: 282253a7e0c51717234bd64159a37ee527d16dc2 qmk_firmware/builddefs/docsgen/.vitepress/theme/QMKLayout.vue -rw-r--r-- 810 bytes
282253a7 — Nick Brassel [docs] Add ability to redirect based on input path. (#23851) 1 year, 4 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<script setup>
import DefaultTheme from 'vitepress/theme'
import { useRouter } from 'vitepress'
import { onBeforeMount } from 'vue';
import aliases from "../../../../docs/_aliases.json";

const router = useRouter()
onBeforeMount(async () => {
    // Convert from docsify-style to vitepress-style URLs
    let newUrl = window.location.href.replace(/\/#\//, '/').replace(/\?id=/, '#');

    // Convert any aliases
    let testUrl = new URL(newUrl);
    while (testUrl.pathname in aliases) {
        testUrl.pathname = aliases[testUrl.pathname];
    }
    newUrl = testUrl.toString();

    // Redirect if required
    if (newUrl != window.location.href) {
        window.history.replaceState({}, '', newUrl);
        await router.go(newUrl);
    }
});
</script>

<template>
    <DefaultTheme.Layout/>
</template>
Do not follow this link