2023-03-03 15:54:28 +00:00
|
|
|
<script setup>
|
|
|
|
import { computed } from 'vue';
|
|
|
|
|
|
|
|
const props = defineProps({
|
2023-10-31 14:38:43 +00:00
|
|
|
username: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
avatar: {
|
|
|
|
type: String,
|
|
|
|
default: null,
|
|
|
|
},
|
|
|
|
api: {
|
|
|
|
type: String,
|
|
|
|
default: 'avataaars',
|
|
|
|
},
|
2023-03-03 15:54:28 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const avatar = computed(
|
2023-10-31 14:38:43 +00:00
|
|
|
// () => props.avatar ?? `https://avatars.dicebear.com/api/${props.api}/${props.username?.replace(/[^a-z0-9]+/i, '-')}.svg`
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-10-31 14:38:43 +00:00
|
|
|
() => props.avatar ?? `https://avatars.dicebear.com/api/initials/${props.username}.svg`,
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-10-31 14:38:43 +00:00
|
|
|
// () => {
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-10-31 14:38:43 +00:00
|
|
|
// return props.avatar ?? `https://www.gravatar.com/avatar/${props.username}?s=50`;
|
|
|
|
// }
|
2023-03-03 15:54:28 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
const username = computed(() => props.username);
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2023-10-31 14:38:43 +00:00
|
|
|
<div>
|
|
|
|
<img :src="avatar" :alt="username" class="rounded-full block h-auto w-full max-w-full bg-gray-100 dark:bg-slate-800" />
|
|
|
|
</div>
|
2023-03-03 15:54:28 +00:00
|
|
|
</template>
|