Skip to content

Commit 8aaca2d

Browse files
fix
1 parent 96713e0 commit 8aaca2d

File tree

2 files changed

+46
-34
lines changed

2 files changed

+46
-34
lines changed

.vuepress/theme/NavLink.vue

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,58 @@
11
<template>
22
<router-link
3-
class="nav-link"
4-
:to="link"
5-
v-if="!isExternal(link)"
6-
:exact="exact"
7-
>{{ item.text }}
3+
class="nav-link"
4+
:to="link"
5+
v-if="!isExternal(link)"
6+
:exact="exact"
7+
>
8+
{{ item.text }}
89
</router-link>
10+
911
<a
10-
v-else
11-
:href="link"
12-
class="nav-link external"
13-
:target="isMailto(link) || isTel(link) ? null : '_blank'"
14-
:rel="isMailto(link) || isTel(link) ? null : 'noopener noreferrer'"
12+
v-else
13+
:href="link"
14+
class="nav-link external"
15+
:target="shouldOpenNewTab(link) ? '_blank' : null"
16+
:rel="shouldOpenNewTab(link) ? 'noopener noreferrer' : null"
1517
>
1618
{{ item.text }}
1719
<OutboundLink/>
1820
</a>
1921
</template>
2022

2123
<script>
22-
import { isExternal, isMailto, isTel, ensureExt } from './util';
24+
import { isExternal, isMailto, isTel, isPterodactylIo, ensureExt } from './util';
2325
24-
export default {
25-
props: {
26-
item: {
27-
required: true
28-
}
26+
export default {
27+
props: {
28+
item: {
29+
required: true
30+
}
31+
},
32+
computed: {
33+
link() {
34+
return ensureExt(this.item.link);
2935
},
30-
computed: {
31-
link() {
32-
return ensureExt(this.item.link);
33-
},
34-
exact() {
35-
if (this.$site.locales) {
36-
return Object.keys(this.$site.locales).some(rootLink => rootLink === this.link);
37-
}
38-
return this.link === '/';
36+
exact() {
37+
if (this.$site.locales) {
38+
return Object.keys(this.$site.locales).some(
39+
rootLink => rootLink === this.link
40+
);
3941
}
40-
},
41-
methods: {
42-
isExternal,
43-
isMailto,
44-
isTel
42+
return this.link === '/';
43+
}
44+
},
45+
methods: {
46+
isExternal,
47+
isMailto,
48+
isTel,
49+
isPterodactylIo,
50+
51+
shouldOpenNewTab(link) {
52+
return !this.isMailto(link)
53+
&& !this.isTel(link)
54+
&& !this.isPterodactylIo(link);
4555
}
46-
};
56+
}
57+
};
4758
</script>

.vuepress/theme/util.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ export function getHash(path) {
1717
}
1818

1919
export function isExternal(path) {
20-
if (/https?:\/\/([^\/]*\.)?pterodactyl\.io/.test(path)) {
21-
return false
22-
}
2320
return outboundRE.test(path)
2421
}
2522

23+
export function isPterodactylIo(path) {
24+
return /https?:\/\/([^\/]*\.)?pterodactyl\.io/.test(path)
25+
}
26+
2627
export function isMailto(path) {
2728
return /^mailto:/.test(path)
2829
}

0 commit comments

Comments
 (0)