handle dynamic team members

pull/4339/head
Divyansh Singh 11 months ago
parent 45332a3510
commit 97aa62093d

@ -1,6 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { DefaultTheme } from 'vitepress/theme' import type { DefaultTheme } from 'vitepress/theme'
import { computed, useSSRContext } from 'vue' import { computed, nextTick, onMounted, ref, useSSRContext } from 'vue'
import type { SSGContext } from '../../shared' import type { SSGContext } from '../../shared'
const props = defineProps<{ const props = defineProps<{
@ -9,12 +9,27 @@ const props = defineProps<{
ariaLabel?: string ariaLabel?: string
}>() }>()
const el = ref<HTMLAnchorElement>()
onMounted(async () => {
await nextTick()
const span = el.value?.children[0]
if (
span instanceof HTMLElement &&
span.className.startsWith('vpi-social-') &&
(getComputedStyle(span).maskImage ||
getComputedStyle(span).webkitMaskImage) === 'none'
) {
span.style.setProperty(
'--icon',
`url('https://api.iconify.design/simple-icons/${props.icon}.svg')`
)
}
})
const svg = computed(() => { const svg = computed(() => {
if (typeof props.icon === 'object') return props.icon.svg if (typeof props.icon === 'object') return props.icon.svg
const style = import.meta.env.DEV return `<span class="vpi-social-${props.icon}"></span>`
? `style="--icon: url('https://api.iconify.design/simple-icons/${props.icon}.svg')" `
: ''
return `<span class="vpi-social-${props.icon}" ${style}></span>`
}) })
if (import.meta.env.SSR) { if (import.meta.env.SSR) {
@ -25,6 +40,7 @@ if (import.meta.env.SSR) {
<template> <template>
<a <a
ref="el"
class="VPSocialLink no-icon" class="VPSocialLink no-icon"
:href="link" :href="link"
:aria-label="ariaLabel ?? (typeof icon === 'string' ? icon : '')" :aria-label="ariaLabel ?? (typeof icon === 'string' ? icon : '')"

Loading…
Cancel
Save