fix: fix hydration mismatch with the "last update" feature (#150)

pull/151/head
Kia King Ishii 4 years ago committed by GitHub
parent 0b181e7582
commit fc725e7295
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -6,7 +6,7 @@
</template>
<script lang="ts">
import { defineComponent, computed } from 'vue'
import { defineComponent, ref, computed, onMounted } from 'vue'
import { useSiteDataByRoute, usePageData } from 'vitepress'
export default defineComponent({
@ -14,6 +14,8 @@ export default defineComponent({
const site = useSiteDataByRoute()
const page = usePageData()
const datetime = ref('')
const hasLastUpdated = computed(() => {
const lu = site.value.themeConfig.lastUpdated
@ -26,8 +28,8 @@ export default defineComponent({
return p === true ? 'Last Updated' : p
})
const datetime = computed(() => {
return new Date(page.value.lastUpdated).toLocaleString('en-US')
onMounted(() => {
datetime.value = new Date(page.value.lastUpdated).toLocaleString('en-US')
})
return {

Loading…
Cancel
Save