docs: add `lastUpdated` example

pull/683/head
Percy Ma 3 years ago committed by GitHub
parent db76b849de
commit 72130a4d36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -40,6 +40,14 @@ export default {
The Last Updated prompt text.
```ts
export default {
themeConfig: {
lastUpdated: 'Updated Date'
}
}
```
## footer
- Type: `Footer`

@ -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)
})
})
</script>

Loading…
Cancel
Save