fix(theme): make last updated time reactive (#879)

pull/881/head
rainkolwa 2 years ago committed by GitHub
parent 29d44e7a22
commit 25a835f0f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,11 +1,11 @@
<script setup lang="ts">
import { ref, watchEffect, onMounted } from 'vue'
import { ref, computed, watchEffect, onMounted } from 'vue'
import { useData } from 'vitepress'
const { theme, page } = useData()
const date = new Date(page.value.lastUpdated!)
const isoDatetime = date.toISOString()
const date = computed(() => new Date(page.value.lastUpdated!))
const isoDatetime = computed(() => date.value.toISOString())
const datetime = ref('')
// set time on mounted hook because the locale string might be different
@ -13,7 +13,7 @@ const datetime = ref('')
// calculated at build time
onMounted(() => {
watchEffect(() => {
datetime.value = date.toLocaleString(window.navigator.language)
datetime.value = date.value.toLocaleString(window.navigator.language)
})
})
</script>

Loading…
Cancel
Save