From 72130a4d368ad58fc7c4f40d5374ba94dca2c1d6 Mon Sep 17 00:00:00 2001 From: Percy Ma Date: Sun, 29 May 2022 16:10:18 +0000 Subject: [PATCH] docs: add `lastUpdated` example --- docs/config/theme-configs.md | 8 ++++++++ src/client/theme-default/components/VPLastUpdated.vue | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/config/theme-configs.md b/docs/config/theme-configs.md index 196885f7..b576a577 100644 --- a/docs/config/theme-configs.md +++ b/docs/config/theme-configs.md @@ -40,6 +40,14 @@ export default { The Last Updated prompt text. +```ts +export default { + themeConfig: { + lastUpdated: 'Updated Date' + } +} +``` + ## footer - Type: `Footer` diff --git a/src/client/theme-default/components/VPLastUpdated.vue b/src/client/theme-default/components/VPLastUpdated.vue index 9bc4fe10..4e8eacca 100644 --- a/src/client/theme-default/components/VPLastUpdated.vue +++ b/src/client/theme-default/components/VPLastUpdated.vue @@ -3,15 +3,15 @@ import { ref, onMounted, watchEffect } from 'vue' import { useData } from 'vitepress' const { theme, page } = useData() -const data = new Date(page.value.lastUpdated!) -const isoDatetime = data.toISOString() +const date = new Date(page.value.lastUpdated!) +const isoDatetime = date.toISOString() const datetime = ref('') onMounted(() => { watchEffect(() => { // locale string might be different based on end user // and will lead to potential hydration mismatch if calculated at build time - datetime.value = data.toLocaleString(window.navigator.language) + datetime.value = date.toLocaleString(window.navigator.language) }) })