Skip to content

Commit 087467a

Browse files
Tiago Cerqueiraulivz
Tiago Cerqueira
authored andcommitted
feat: handle telephone links (#325)
1 parent f4de118 commit 087467a

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

Diff for: lib/default-theme/NavLink.vue

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
v-else
1010
:href="link"
1111
class="nav-link"
12-
:target="isMailto(link) ? null : '_blank'"
13-
:rel="isMailto(link) ? null : 'noopener noreferrer'"
12+
:target="isMailto(link) || isTel(link) ? null : '_blank'"
13+
:rel="isMailto(link) || isTel(link) ? null : 'noopener noreferrer'"
1414
>{{ item.text }}</a>
1515
</template>
1616

1717
<script>
18-
import { isExternal, isMailto, ensureExt } from './util'
18+
import { isExternal, isMailto, isTel, ensureExt } from './util'
1919
2020
export default {
2121
props: {
@@ -30,7 +30,8 @@ export default {
3030
},
3131
methods: {
3232
isExternal,
33-
isMailto
33+
isMailto,
34+
isTel
3435
}
3536
}
3637
</script>

Diff for: lib/default-theme/util.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export const hashRE = /#.*$/
22
export const extRE = /\.(md|html)$/
33
export const endingSlashRE = /\/$/
4-
export const outboundRE = /^(https?:|mailto:)/
4+
export const outboundRE = /^(https?:|mailto:|tel:)/
55

66
export function normalize (path) {
77
return path
@@ -24,6 +24,10 @@ export function isMailto (path) {
2424
return /^mailto:/.test(path)
2525
}
2626

27+
export function isTel (path) {
28+
return /^tel:/.test(path)
29+
}
30+
2731
export function ensureExt (path) {
2832
if (isExternal(path)) {
2933
return path

0 commit comments

Comments
 (0)