2023-12-22 12:16:46 +00:00
|
|
|
<script setup lang="ts">
|
2024-02-21 15:20:08 +00:00
|
|
|
const { as, alt, dataEmojiId } = defineProps<{
|
2023-12-22 12:16:46 +00:00
|
|
|
as: string
|
|
|
|
alt?: string
|
|
|
|
dataEmojiId?: string
|
|
|
|
}>()
|
|
|
|
|
2024-02-21 15:20:08 +00:00
|
|
|
const title = ref<string | undefined>()
|
2023-12-22 12:16:46 +00:00
|
|
|
|
|
|
|
if (alt) {
|
|
|
|
if (alt.startsWith(':')) {
|
2024-02-21 15:20:08 +00:00
|
|
|
title.value = alt.replace(/:/g, '')
|
2023-12-22 12:16:46 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
import('node-emoji').then(({ find }) => {
|
2024-02-21 15:20:08 +00:00
|
|
|
title.value = find(alt)?.key.replace(/_/g, ' ')
|
2023-12-22 12:16:46 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if it has a data-emoji-id, use that as the title instead
|
|
|
|
if (dataEmojiId)
|
2024-02-21 15:20:08 +00:00
|
|
|
title.value = dataEmojiId
|
2023-12-22 12:16:46 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<component :is="as" v-bind="$attrs" :alt="alt" :data-emoji-id="dataEmojiId" :title="title">
|
|
|
|
<slot />
|
|
|
|
</component>
|
|
|
|
</template>
|