feat(theme): allow forcing site locale in last updated format (#2973)

pull/2974/head
Divyansh Singh 10 months ago committed by GitHub
parent 0d96620409
commit a18e5e48a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -331,7 +331,7 @@ export interface LastUpdatedOptions {
* @default
* { dateStyle: 'short', timeStyle: 'short' }
*/
formatOptions?: Intl.DateTimeFormatOptions
formatOptions?: Intl.DateTimeFormatOptions & { forceLocale?: boolean }
}
```

@ -2,7 +2,7 @@
import { ref, computed, watchEffect, onMounted } from 'vue'
import { useData } from '../composables/data'
const { theme, page, frontmatter } = useData()
const { theme, page, frontmatter, lang } = useData()
const date = computed(
() => new Date(frontmatter.value.lastUpdated ?? page.value.lastUpdated)
@ -15,7 +15,7 @@ const datetime = ref('')
onMounted(() => {
watchEffect(() => {
datetime.value = new Intl.DateTimeFormat(
undefined,
theme.value.lastUpdated?.formatOptions?.forceLocale ? lang.value : undefined,
theme.value.lastUpdated?.formatOptions ?? {
dateStyle: 'short',
timeStyle: 'short'

@ -435,7 +435,7 @@ export namespace DefaultTheme {
* @default
* { dateStyle: 'short', timeStyle: 'short' }
*/
formatOptions?: Intl.DateTimeFormatOptions
formatOptions?: Intl.DateTimeFormatOptions & { forceLocale?: boolean }
}
// not found -----------------------------------------------------------------

Loading…
Cancel
Save