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

pull/2974/head
Divyansh Singh 1 year 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 * @default
* { dateStyle: 'short', timeStyle: 'short' } * { dateStyle: 'short', timeStyle: 'short' }
*/ */
formatOptions?: Intl.DateTimeFormatOptions formatOptions?: Intl.DateTimeFormatOptions & { forceLocale?: boolean }
} }
``` ```

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

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

Loading…
Cancel
Save