File tree 2 files changed +8
-7
lines changed
2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -42,15 +42,16 @@ export default {
42
42
} ,
43
43
$langConfig ( ) {
44
44
const { langs } = this . $site
45
+ let targetLang
45
46
let defaultLang
46
- const lang = ( langs || [ ] ) . find ( ( lang , index ) => {
47
+ ( langs || [ ] ) . forEach ( ( lang , index ) => {
47
48
if ( lang . path === '/' ) {
48
49
defaultLang = langs [ index ]
49
- } else {
50
- return this . $page . path . startsWith ( lang . path )
50
+ } else if ( this . $page . path . indexOf ( lang . path ) === 0 ) {
51
+ targetLang = langs [ index ]
51
52
}
52
53
} )
53
- return lang || defaultLang
54
+ return targetLang || defaultLang
54
55
} ,
55
56
$lang ( ) {
56
57
return this . $langConfig && this . $langConfig . lang || 'en'
Original file line number Diff line number Diff line change @@ -29,13 +29,13 @@ import NavLink from './NavLink.vue'
29
29
export default {
30
30
components: { OutboundLink, NavLink, DropdownLink },
31
31
computed: {
32
- userNav () {
32
+ userNav () {
33
33
if (Array .isArray (this .$site .themeConfig .nav )) {
34
34
return this .$site .themeConfig .nav
35
35
}
36
36
return this .$site .themeConfig .nav [this .$basepath ]
37
37
},
38
- nav () {
38
+ nav () {
39
39
if (this .$site .langs && this .$site .langs .length ) {
40
40
let currentLink = this .$page .path
41
41
const routes = this .$router .options .routes
@@ -51,7 +51,7 @@ export default {
51
51
// Try to stay on the same page
52
52
link = currentLink .replace (this .$langConfig .path , lang .path )
53
53
// fallback to homepage
54
- if (! routes .find (route => route .path === link)) {
54
+ if (! routes .some (route => route .path === link)) {
55
55
link = lang .path
56
56
}
57
57
}
You can’t perform that action at this time.
0 commit comments