-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
VPSocialLink.vue
51 lines (45 loc) · 969 Bytes
/
VPSocialLink.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
<script lang="ts" setup>
import type { DefaultTheme } from 'vitepress/theme'
import { computed } from 'vue'
import { icons } from '../support/socialIcons'
const props = defineProps<{
icon: DefaultTheme.SocialLinkIcon
link: string
ariaLabel?: string
}>()
const svg = computed(() => {
if (typeof props.icon === 'object') return props.icon.svg
return icons[props.icon]
})
</script>
<template>
<a
class="VPSocialLink no-icon"
:href="link"
:aria-label="ariaLabel ?? (typeof icon === 'string' ? icon : '')"
target="_blank"
rel="noopener"
v-html="svg"
>
</a>
</template>
<style scoped>
.VPSocialLink {
display: flex;
justify-content: center;
align-items: center;
width: 36px;
height: 36px;
color: var(--vp-c-text-2);
transition: color 0.5s;
}
.VPSocialLink:hover {
color: var(--vp-c-text-1);
transition: color 0.25s;
}
.VPSocialLink > :deep(svg) {
width: 20px;
height: 20px;
fill: currentColor;
}
</style>