Skip to content

Commit a18e5e4

Browse files
authoredSep 15, 2023
feat(theme): allow forcing site locale in last updated format (#2973)
1 parent 0d96620 commit a18e5e4

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed
 

‎docs/reference/default-theme-config.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ export interface LastUpdatedOptions {
331331
* @default
332332
* { dateStyle: 'short', timeStyle: 'short' }
333333
*/
334-
formatOptions?: Intl.DateTimeFormatOptions
334+
formatOptions?: Intl.DateTimeFormatOptions & { forceLocale?: boolean }
335335
}
336336
```
337337

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { ref, computed, watchEffect, onMounted } from 'vue'
33
import { useData } from '../composables/data'
44
5-
const { theme, page, frontmatter } = useData()
5+
const { theme, page, frontmatter, lang } = useData()
66
77
const date = computed(
88
() => new Date(frontmatter.value.lastUpdated ?? page.value.lastUpdated)
@@ -15,7 +15,7 @@ const datetime = ref('')
1515
onMounted(() => {
1616
watchEffect(() => {
1717
datetime.value = new Intl.DateTimeFormat(
18-
undefined,
18+
theme.value.lastUpdated?.formatOptions?.forceLocale ? lang.value : undefined,
1919
theme.value.lastUpdated?.formatOptions ?? {
2020
dateStyle: 'short',
2121
timeStyle: 'short'

‎types/default-theme.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ export namespace DefaultTheme {
435435
* @default
436436
* { dateStyle: 'short', timeStyle: 'short' }
437437
*/
438-
formatOptions?: Intl.DateTimeFormatOptions
438+
formatOptions?: Intl.DateTimeFormatOptions & { forceLocale?: boolean }
439439
}
440440

441441
// not found -----------------------------------------------------------------

0 commit comments

Comments
 (0)
Please sign in to comment.