This repository was archived by the owner on Dec 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAppNav.vue
143 lines (138 loc) · 4.57 KB
/
AppNav.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<template>
<aside
class="w-full lg:w-1/5 lg:block fixed lg:relative inset-0 mt-16 lg:mt-0 z-30 bg-white dark:bg-gray-900 lg:bg-transparent lg:dark:bg-transparent"
:class="{ 'block': menu, 'hidden': !menu }"
>
<div class="lg:sticky lg:top-16 overflow-y-auto h-full lg:h-auto lg:max-h-(screen-16)">
<ul class="p-4 lg:py-8 lg:pl-0 lg:pr-8">
<li v-if="!settings.algolia" class="mb-4 lg:hidden">
<AppSearch />
</li>
<li
v-for="(docs, category, index) in categories"
:key="category"
class="mb-4"
:class="{
'active': isCategoryActive(docs),
'lg:mb-0': index === Object.keys(categories).length - 1
}"
>
<p
class="mb-2 text-gray-500 uppercase tracking-wider font-bold text-sm lg:text-xs"
>{{ category }}</p>
<ul>
<li v-for="doc of docs" :key="doc.slug" class="text-gray-700 dark:text-gray-300">
<NuxtLink
:to="localePath(doc.to)"
class="px-2 rounded font-medium py-1 hover:text-primary-500 flex items-center justify-between"
exact-active-class="text-primary-500 bg-primary-100 hover:text-primary-500 dark:bg-primary-900"
>
{{ doc.menuTitle || doc.title }}
<client-only>
<span
v-if="isDocumentNew(doc)"
class="animate-pulse rounded-full bg-primary-500 opacity-75 h-2 w-2"
/>
</client-only>
</NuxtLink>
</li>
</ul>
</li>
<li class="lg:hidden">
<p class="mb-2 text-gray-500 uppercase tracking-wider font-bold text-sm lg:text-xs">More</p>
<div class="flex items-center ml-2">
<a
v-if="settings.linkedin"
:href="`https://www.linkedin.com/company/${settings.linkedin}/?viewAsMember=true`"
target="_blank"
rel="noopener noreferrer"
title="LinkendIn"
name="LinkendIn"
class="text-gray-700 dark:text-gray-300 hover:text-primary-500 dark-hover:text-primary-500 ml-4"
:class="{
'hidden lg:block': settings.layout !== 'single'
}"
>
<IconLinkendin class="w-5 h-5" />
</a>
<a
v-if="settings.youtube"
:href="`https://www.youtube.com/c/${settings.youtube}`"
target="_blank"
rel="noopener noreferrer"
title="YouTube"
name="YouT`ube"
class="inline-flex text-gray-700 dark:text-gray-300 hover:text-primary-500 mr-4"
>
<IconYoutube class="w-5 h-5" />
</a>
<a
v-if="settings.twitter"
:href="`https://twitter.com/${settings.twitter}`"
target="_blank"
rel="noopener noreferrer"
title="Twitter"
name="Twitter"
class="inline-flex text-gray-700 dark:text-gray-300 hover:text-primary-500 mr-4"
>
<IconTwitter class="w-5 h-5" />
</a>
<a
v-if="settings.github"
:href="githubUrls.repo"
target="_blank"
rel="noopener noreferrer"
title="Github"
name="Github"
class="inline-flex text-gray-700 dark:text-gray-300 hover:text-primary-500 mr-4"
>
<IconGithub class="w-5 h-5" />
</a>
<AppLangSwitcher class="mr-4" />
<AppColorSwitcher />
</div>
</li>
</ul>
</div>
</aside>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
computed: {
...mapGetters([
'settings',
'githubUrls'
]),
menu: {
get () {
return this.$store.state.menu.open
},
set (val) {
this.$store.commit('menu/toggle', val)
}
},
categories () {
return this.$store.state.categories[this.$i18n.locale]
}
},
methods: {
isCategoryActive (documents) {
return documents.some(document => document.to === this.$route.fullPath)
},
isDocumentNew (document) {
if (process.server) {
return
}
if (!document.version || document.version <= 0) {
return
}
const version = localStorage.getItem(`document-${document.slug}-version`)
if (document.version > Number(version)) {
return true
}
return false
}
}
}
</script>