/
VPSidebarLink.vue
54 lines (45 loc) · 959 Bytes
/
VPSidebarLink.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
<script lang="ts" setup>
import { inject } from 'vue'
import { useData } from 'vitepress'
import { DefaultTheme } from '../config'
import { isActive, normalizeLink } from '../support/utils'
import VPLink from './VPLink.vue'
defineProps<{
item: DefaultTheme.SidebarItem
}>()
const { page } = useData()
const closeSideBar = inject('close-sidebar') as () => void
</script>
<template>
<VPLink
:class="{ active: isActive(page.relativePath, item.link) }"
:href="item.link"
@click="closeSideBar"
>
<span class="link-text">{{ item.text }}</span>
</VPLink>
</template>
<style scoped>
.link {
display: block;
padding: 4px 0;
color: var(--vp-c-text-2);
transition: color 0.5s;
}
.link:hover {
color: var(--vp-c-text-1);
}
.link.active {
color: var(--vp-c-brand);
}
.link :deep(.icon) {
width: 12px;
height: 12px;
fill: currentColor;
}
.link-text {
line-height: 20px;
font-size: 14px;
font-weight: 500;
}
</style>