Skip to content

Commit 25a835f

Browse files
authored
fix(theme): make last updated time reactive (#879)
1 parent 29d44e7 commit 25a835f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/client/theme-default/components/VPDocFooterLastUpdated.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<script setup lang="ts">
2-
import { ref, watchEffect, onMounted } from 'vue'
2+
import { ref, computed, watchEffect, onMounted } from 'vue'
33
import { useData } from 'vitepress'
44
55
const { theme, page } = useData()
66
7-
const date = new Date(page.value.lastUpdated!)
8-
const isoDatetime = date.toISOString()
7+
const date = computed(() => new Date(page.value.lastUpdated!))
8+
const isoDatetime = computed(() => date.value.toISOString())
99
const datetime = ref('')
1010
1111
// set time on mounted hook because the locale string might be different
1212
// based on end user and will lead to potential hydration mismatch if
1313
// calculated at build time
1414
onMounted(() => {
1515
watchEffect(() => {
16-
datetime.value = date.toLocaleString(window.navigator.language)
16+
datetime.value = date.value.toLocaleString(window.navigator.language)
1717
})
1818
})
1919
</script>

0 commit comments

Comments
 (0)