<script lang="ts" setup>
import { httpsCallable } from 'firebase/functions'
const { $fireFunctions } = useNuxtApp()
const { normalizedUser } = useNormalizer()
const route = useRoute()
const slug = ref(route.params.id)
const { data: player, pending: pendingPlayer } = await useAsyncData('player', async () => {
const getFirePlayer = httpsCallable($fireFunctions as any, 'getUser')
const res: any = await getFirePlayer({ username: slug.value })
return normalizedUser(res.data.data)
}, {
server: false,
watch: [slug]
})
useSeoMeta({
title: () => `${player.value?.userData?.username ? 'NEEFT - Profil de ' + player.value?.userData?.username : 'NEEFT - Profil de joueur'}`,
description: () => player.value?.userData?.ambition?.substring(0, 160) || '',
ogTitle: () => `${player.value?.userData?.username ? 'NEEFT - Profil de ' + player.value?.userData?.username : 'NEEFT - Profil de joueur'}`,
ogImage: () => player.value?.userData?.customization?.avatarUrl,
ogDescription: () => player.value?.userData?.ambition?.substring(0, 160) || '',
ogUrl: () => `https://www.neeft.fr${route.path}`,
twitterTitle: () => `${player.value?.userData?.username ? 'NEEFT - Profil de ' + player.value?.userData?.username : 'NEEFT - Profil de joueur'}`,
twitterDescription: () => player.value?.userData?.ambition?.substring(0, 160) || '',
twitterImage: () => player.value?.userData?.customization?.avatarUrl,
twitterCard: () => 'summary'
})
</script>