diff --git a/builddefs/docsgen/.vitepress/theme/QMKLayout.vue b/builddefs/docsgen/.vitepress/theme/QMKLayout.vue index 30d0780d7c3..9d7a41f9e2d 100644 --- a/builddefs/docsgen/.vitepress/theme/QMKLayout.vue +++ b/builddefs/docsgen/.vitepress/theme/QMKLayout.vue @@ -2,11 +2,22 @@ import DefaultTheme from 'vitepress/theme' import { useRouter } from 'vitepress' import { onBeforeMount } from 'vue'; +import aliases from "../../../../docs/_aliases.json"; const router = useRouter() onBeforeMount(async () => { - if (window.location.href.includes('/#/')) { - const newUrl = window.location.href.replace(/\/#\//, '/').replace(/\?id=/, '#'); + // 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); } diff --git a/docs/_aliases.json b/docs/_aliases.json new file mode 100644 index 00000000000..a2224bd0d54 --- /dev/null +++ b/docs/_aliases.json @@ -0,0 +1,74 @@ +{ + "/adding_a_keyboard_to_qmk": "/hardware_keyboard_guidelines", + "/build_environment_setup": "/newbs_getting_started", + "/cli_dev_configuration": "/cli_configuration", + "/dynamic_macros": "/feature_dynamic_macros", + "/feature_common_shortcuts": "/feature_advanced_keycodes", + "/getting_started_build_tools": "/newbs_getting_started", + "/getting_started_getting_help": "/support", + "/glossary": "/reference_glossary", + "/key_lock": "/feature_key_lock", + "/make_instructions": "/getting_started_make_guide", + "/python_development": "/cli_development", + "/space_cadet_shift": "/feature_space_cadet_shift", + "/tap_dance": "/feature_tap_dance", + "/tutorial": "/newbs", + "/unicode": "/feature_unicode", + + "/adc_driver": "/drivers/adc", + "/apa102_driver": "/drivers/apa102", + "/audio_driver": "/drivers/audio", + "/eeprom_driver": "/drivers/eeprom", + "/feature_audio": "/features/audio", + "/feature_auto_shift": "/features/auto_shift", + "/feature_autocorrect": "/features/autocorrect", + "/feature_backlight": "/features/backlight", + "/feature_bluetooth": "/features/bluetooth", + "/feature_bootmagic": "/features/bootmagic", + "/feature_caps_word": "/features/caps_word", + "/feature_combo": "/features/combo", + "/feature_command": "/features/command", + "/feature_digitizer": "/features/digitizer", + "/feature_dip_switch": "/features/dip_switch", + "/feature_dynamic_macros": "/features/dynamic_macros", + "/feature_encoders": "/features/encoders", + "/feature_grave_esc": "/features/grave_esc", + "/feature_haptic_feedback": "/features/haptic_feedback", + "/feature_hd44780": "/features/hd44780", + "/feature_joystick": "/features/joystick", + "/feature_key_lock": "/features/key_lock", + "/feature_key_overrides": "/features/key_overrides", + "/feature_leader_key": "/features/leader_key", + "/feature_led_indicators": "/features/led_indicators", + "/feature_led_matrix": "/features/led_matrix", + "/feature_midi": "/features/midi", + "/feature_mouse_keys": "/features/mouse_keys", + "/feature_oled_driver": "/features/oled_driver", + "/feature_os_detection": "/features/os_detection", + "/feature_pointing_device": "/features/pointing_device", + "/feature_programmable_button": "/features/programmable_button", + "/feature_ps2_mouse": "/features/ps2_mouse", + "/feature_rawhid": "/features/rawhid", + "/feature_repeat_key": "/features/repeat_key", + "/feature_rgb_matrix": "/features/rgb_matrix", + "/feature_rgblight": "/features/rgblight", + "/feature_secure": "/features/secure", + "/feature_send_string": "/features/send_string", + "/feature_sequencer": "/features/sequencer", + "/feature_space_cadet": "/features/space_cadet", + "/feature_split_keyboard": "/features/split_keyboard", + "/feature_st7565": "/features/st7565", + "/feature_stenography": "/features/stenography", + "/feature_swap_hands": "/features/swap_hands", + "/feature_tap_dance": "/features/tap_dance", + "/feature_tri_layer": "/features/tri_layer", + "/feature_unicode": "/features/unicode", + "/feature_wpm": "/features/wpm", + "/flash_driver": "/drivers/flash", + "/gpio_control": "/drivers/gpio", + "/i2c_driver": "/drivers/i2c", + "/serial_driver": "/drivers/serial", + "/spi_driver": "/drivers/spi", + "/uart_driver": "/drivers/uart", + "/ws2812_driver": "/drivers/ws2812" +}