-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
Copy pathNavLinks.vue
88 lines (82 loc) · 1.92 KB
/
NavLinks.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<template>
<nav class="nav-links" v-if="userLinks.length || githubLink">
<!-- user links -->
<div
class="nav-item"
v-for="item in userLinks"
:key="item.link">
<dropdown-link
v-if="item.type === 'links'"
:item="item"></dropdown-link>
<nav-link v-else :item="item"></nav-link>
</div>
<!-- github link -->
<a v-if="githubLink"
:href="githubLink"
class="github-link"
target="_blank"
rel="noopener">
GitHub
<OutboundLink/>
</a>
</nav>
</template>
<script>
import OutboundLink from './OutboundLink.vue'
import { isActive, resolveNavLinkItem } from './util'
import NavLink from './NavLink.vue'
import DropdownLink from './DropdownLink.vue'
export default {
components: { OutboundLink, NavLink, DropdownLink },
computed: {
userLinks () {
return (this.$site.themeConfig.nav || []).map((link => {
return Object.assign(resolveNavLinkItem(link), {
items: (link.items || []).map(resolveNavLinkItem)
})
}))
},
githubLink () {
const { repo } = this.$site.themeConfig
if (repo) {
return /^https?:/.test(repo)
? repo
: `https://github.com/${repo}`
}
}
},
methods: {
isActive
}
}
</script>
<style lang="stylus">
@import './styles/config.styl'
.nav-links
display inline-block
a
line-height 1.25rem
color inherit
&:hover, &.router-link-active
color $accentColor
.nav-item
cursor: pointer
position relative
display inline-block
margin-left 1.5rem
font-weight 500
line-height 2rem
.github-link
margin-left 1.5rem
@media (max-width: $MQMobile)
.nav-links
.nav-item, .github-link
margin-left 0
@media (min-width: $MQMobile)
.nav-links
a
&:hover, &.router-link-active
color $textColor
margin-bottom -2px
border-bottom 2px solid lighten($accentColor, 5%)
</style>