File tree Expand file tree Collapse file tree 3 files changed +62
-18
lines changed Expand file tree Collapse file tree 3 files changed +62
-18
lines changed Original file line number Diff line number Diff line change @@ -423,23 +423,28 @@ module.exports = {
423
423
// Translation maintainers: Please include the link below to the English documentation
424
424
{
425
425
text : 'English' ,
426
- link : 'https://v3.vuejs.org/'
426
+ link : 'https://v3.vuejs.org/' ,
427
+ isTranslation : true
427
428
} ,
428
429
{
429
430
text : '中文' ,
430
- link : 'https://v3.cn.vuejs.org/'
431
+ link : 'https://v3.cn.vuejs.org/' ,
432
+ isTranslation : true
431
433
} ,
432
434
{
433
435
text : '한국어' ,
434
- link : 'https://v3.ko.vuejs.org/'
436
+ link : 'https://v3.ko.vuejs.org/' ,
437
+ isTranslation : true
435
438
} ,
436
439
// {
437
- // text: '日本語',
438
- // link: 'https://v3.ja.vuejs.org/'
440
+ // text: '日本語',
441
+ // link: 'https://v3.ja.vuejs.org/',
442
+ // isTranslation: true
439
443
// },
440
444
{
441
445
text : 'Русский' ,
442
- link : 'https://v3.ru.vuejs.org/'
446
+ link : 'https://v3.ru.vuejs.org/ru/' ,
447
+ isTranslation : true
443
448
} ,
444
449
{
445
450
text : 'その他の翻訳' ,
Original file line number Diff line number Diff line change 22
22
</template >
23
23
24
24
<script >
25
+ import Vue from ' vue'
25
26
import { isExternal , isMailto , isTel , ensureExt } from ' ../util'
26
27
28
+ const pageLocation = Vue .observable ({ path: ' /' })
29
+
30
+ let initPath = () => {
31
+ initPath = () => {}
32
+
33
+ const updatePath = () => {
34
+ pageLocation .path = location .pathname
35
+ }
36
+
37
+ updatePath ()
38
+
39
+ // There is no event for detecting navigation but these cover most cases
40
+ for (const event of [' focusin' , ' scroll' , ' mouseover' , ' keydown' ]) {
41
+ window .addEventListener (event , updatePath)
42
+ }
43
+ }
44
+
27
45
export default {
28
46
name: ' NavLink' ,
29
47
@@ -35,7 +53,13 @@ export default {
35
53
36
54
computed: {
37
55
link () {
38
- return ensureExt (this .item .link )
56
+ let link = ensureExt (this .item .link )
57
+
58
+ if (this .item .isTranslation ) {
59
+ link = link .replace (/ \/ $ / , ' ' ) + pageLocation .path
60
+ }
61
+
62
+ return link
39
63
},
40
64
41
65
exact () {
@@ -68,7 +92,7 @@ export default {
68
92
},
69
93
70
94
rel () {
71
- if (this .isNonHttpURI ) {
95
+ if (this .isNonHttpURI || this . item . isTranslation ) {
72
96
return null
73
97
}
74
98
if (this .item .rel ) {
@@ -82,6 +106,10 @@ export default {
82
106
focusoutAction () {
83
107
this .$emit (' focusout' )
84
108
}
109
+ },
110
+
111
+ mounted () {
112
+ initPath ()
85
113
}
86
114
}
87
115
</script >
Original file line number Diff line number Diff line change 3
3
<div class =" theme-default-content" >
4
4
<h1 >404</h1 >
5
5
6
- <blockquote >{{ getMsg() }}</blockquote >
6
+ <blockquote >
7
+ <p >Whoops! This page doesn't exist.</p >
8
+ </blockquote >
9
+
10
+ <p v-show =" isTranslation" >
11
+ New pages are added to the documentation all the time. This page might not be included in all of the translations yet.
12
+ </p >
7
13
8
14
<RouterLink to =" /" >
9
15
Take me home.
13
19
</template >
14
20
15
21
<script >
16
- const msgs = [
17
- ` There's nothing here.` ,
18
- ` How did we get here?` ,
19
- ` That's a Four-Oh-Four.` ,
20
- ` Looks like we've got some broken links.`
21
- ]
22
+ import { repos } from ' ../../components/guide/contributing/translations-data.js'
22
23
23
24
export default {
24
- methods: {
25
- getMsg () {
26
- return msgs[Math .floor (Math .random () * msgs .length )]
25
+ data () {
26
+ return {
27
+ isTranslation: false
28
+ }
29
+ },
30
+
31
+ mounted () {
32
+ const toOrigin = url => (String (url).match (/ https? :\/\/ [^ /] + / ) || [])[0 ]
33
+ const referrer = toOrigin (document .referrer )
34
+
35
+ // Did we get here from a translation?
36
+ if (referrer && referrer !== location .origin && repos .some (({ url }) => toOrigin (url) === referrer)) {
37
+ this .isTranslation = true
27
38
}
28
39
}
29
40
}
You can’t perform that action at this time.
0 commit comments