2
2
// import ParentLayout from '@vuepress/theme-default/layouts/Layout.vue'
3
3
import { Layout as ParentLayout , PageContent } from ' vuepress-theme-hope/client'
4
4
import { useRoute , useRouter } from " vue-router" ;
5
- import { ref } from ' vue'
5
+ import { ref , onMounted } from ' vue'
6
6
7
7
const version = ref (" " );
8
8
@@ -11,8 +11,10 @@ function setVersionBasedOnCurrentPath() : void {
11
11
if (route .path .startsWith (' /operations/' )) {
12
12
const input = route .path .substring (' /operations/' .length );
13
13
const firstSlash = input .indexOf (" /" );
14
- const result = firstSlash !== - 1 ? input .slice (0 , firstSlash ) : input ;
15
-
14
+ var result = firstSlash !== - 1 ? input .slice (0 , firstSlash ) : input ;
15
+ if (result === " latest" ) {
16
+ result = document .querySelector (" #version-select > option[latest='true']" ).value ;
17
+ }
16
18
version .value = result ;
17
19
18
20
@@ -29,13 +31,20 @@ router.afterEach((_to, _from) => {
29
31
setVersionBasedOnCurrentPath ();
30
32
});
31
33
32
- setVersionBasedOnCurrentPath ();
34
+ onMounted (() => {
35
+ setVersionBasedOnCurrentPath ();
36
+ })
33
37
34
38
function navigateToNewVersion() {
35
39
const input = route .path .substring (' /operations/' .length );
36
40
const firstSlash = input .indexOf (" /" );
37
41
const result = firstSlash !== - 1 ? input .slice (firstSlash + 1 ) : " " ;
38
- router .push (' /operations/' + version .value + " /" + result );
42
+ if (version .value === document .querySelector (" #version-select > option[latest='true']" ).value ) {
43
+ router .push (' /operations/' + " latest" + " /" + result );
44
+ } else {
45
+ router .push (' /operations/' + version .value + " /" + result );
46
+
47
+ }
39
48
}
40
49
41
50
</script >
@@ -46,8 +55,7 @@ function navigateToNewVersion() {
46
55
<div class =" version-selector" v-if =" route.path.startsWith('/operations/')" >
47
56
<label class =" vp-sidebar-header" for =" version-select" ><strong >Version:</strong > </label >
48
57
<select id =" version-select" class =" vp-sidebar-header" v-model =" version" @change =" navigateToNewVersion" >
49
- <option value =" next" >next (2.0.0-M3)</option >
50
- <option value =" latest" >latest (1.8.0)</option >
58
+ <option value =" v1.8.0" latest =" true" >latest (1.8.0)</option >
51
59
<option value =" v1.7.1" >1.7.1</option >
52
60
<option value =" v1.7.0" >1.7.0</option >
53
61
<option value =" v1.6.0" >1.6.0</option >
@@ -61,6 +69,7 @@ function navigateToNewVersion() {
61
69
<option value =" v1.2.0" >1.2.0</option >
62
70
<option value =" v1.1.0" >1.1.0</option >
63
71
<option value =" v1.0.0" >1.0.0</option >
72
+ <option value =" v2.0.0-M3" >2.0.0-M3</option >
64
73
</select ></div >
65
74
</template >
66
75
<PageContent id =" main-content" class =" vp-page" />
0 commit comments