mirror of
https://github.com/tachiyomiorg/website.git
synced 2024-12-21 07:31:58 +01:00
Fix the hydration issue on release date (#31)
* Fix the hydration issue on release date. * Show the exact date while rendering instead.
This commit is contained in:
parent
3dca7e2dca
commit
e57a37e9cc
@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, toRefs } from "vue"
|
import { computed, onMounted, ref, toRefs } from "vue"
|
||||||
import moment from "moment"
|
import moment from "moment"
|
||||||
import { type AppRelease, data as release } from "../data/release.data"
|
import { type AppRelease, data as release } from "../data/release.data"
|
||||||
|
|
||||||
@ -11,10 +11,20 @@ const momentInfo = computed(() => ({
|
|||||||
exact: moment(release[type.value].published_at).format("dddd, MMMM Do YYYY [at] HH:mm"),
|
exact: moment(release[type.value].published_at).format("dddd, MMMM Do YYYY [at] HH:mm"),
|
||||||
iso: release[type.value].published_at ?? undefined,
|
iso: release[type.value].published_at ?? undefined,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
// Mimic the <ClientOnly /> behavior to show custom text while rendering.
|
||||||
|
const show = ref(false)
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
show.value = true
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<time :datetime="momentInfo.iso" :title="momentInfo.exact">
|
<time v-if="show" :datetime="momentInfo.iso" :title="momentInfo.exact">
|
||||||
{{ momentInfo.relative }}
|
{{ momentInfo.relative }}
|
||||||
</time>
|
</time>
|
||||||
|
<time v-else :datetime="momentInfo.iso">
|
||||||
|
{{ momentInfo.exact }}
|
||||||
|
</time>
|
||||||
</template>
|
</template>
|
||||||
|
Loading…
Reference in New Issue
Block a user