diff --git a/docs/src/.vuepress/layouts/PageLayout.vue b/docs/src/.vuepress/layouts/PageLayout.vue index ac47d8c33..f4fb8d29c 100644 --- a/docs/src/.vuepress/layouts/PageLayout.vue +++ b/docs/src/.vuepress/layouts/PageLayout.vue @@ -2,7 +2,7 @@ // import ParentLayout from '@vuepress/theme-default/layouts/Layout.vue' import { Layout as ParentLayout, PageContent } from 'vuepress-theme-hope/client' import { useRoute, useRouter } from "vue-router"; -import { ref } from 'vue' +import { ref, onMounted } from 'vue' const version = ref(""); @@ -11,8 +11,10 @@ function setVersionBasedOnCurrentPath() : void { if (route.path.startsWith('/operations/')) { const input = route.path.substring('/operations/'.length); const firstSlash = input.indexOf("/"); - const result = firstSlash !== -1 ? input.slice(0, firstSlash) : input; - + var result = firstSlash !== -1 ? input.slice(0, firstSlash) : input; + if (result === "latest") { + result = document.querySelector("#version-select > option[latest='true']").value; + } version.value = result; @@ -29,13 +31,20 @@ router.afterEach((_to, _from) => { setVersionBasedOnCurrentPath(); }); -setVersionBasedOnCurrentPath(); +onMounted(() => { + setVersionBasedOnCurrentPath(); +}) function navigateToNewVersion() { const input = route.path.substring('/operations/'.length); const firstSlash = input.indexOf("/"); const result = firstSlash !== -1 ? input.slice(firstSlash + 1) : ""; - router.push('/operations/' + version.value + "/" + result); + if (version.value === document.querySelector("#version-select > option[latest='true']").value) { + router.push('/operations/' + "latest" + "/" + result); + } else { + router.push('/operations/' + version.value + "/" + result); + + } } @@ -46,8 +55,7 @@ function navigateToNewVersion() {