mirror of
https://github.com/ArthurDanjou/artsite.git
synced 2026-01-31 12:29:25 +01:00
Merge pull request #2
fix: use use-fetch to avoid to refetch during hydration
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { Stats } from '~~/types'
|
import type { Stats } from '~~/types'
|
||||||
|
|
||||||
const stats = await $fetch<Stats>('/api/stats')
|
const { data: stats } = await useFetch<Stats>('/api/stats')
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -13,7 +13,9 @@ const stats = await $fetch<Stats>('/api/stats')
|
|||||||
}}</strong> hours.
|
}}</strong> hours.
|
||||||
My best editors are
|
My best editors are
|
||||||
{{ stats.editors.data.slice(0, 2).map(editor => `${editor.name} (${editor.percent}%)`).join(' and ') }}.
|
{{ stats.editors.data.slice(0, 2).map(editor => `${editor.name} (${editor.percent}%)`).join(' and ') }}.
|
||||||
|
<template v-if="stats.os.data[0]">
|
||||||
My best OS is {{ stats.os.data[0].name }} ({{ stats.os.data[0].percent }}%).
|
My best OS is {{ stats.os.data[0].name }} ({{ stats.os.data[0].percent }}%).
|
||||||
|
</template>
|
||||||
My top languages are
|
My top languages are
|
||||||
{{ stats.languages.data.slice(0, 2).map(language => `${language.name} (${language.percent}%)`).join(' and ') }}.
|
{{ stats.languages.data.slice(0, 2).map(language => `${language.name} (${language.percent}%)`).join(' and ') }}.
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user