Skip to content

Commit

Permalink
feat(theme): allow forcing site locale in last updated format (#2973)
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed Sep 15, 2023
1 parent 0d96620 commit a18e5e4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/reference/default-theme-config.md
Expand Up @@ -331,7 +331,7 @@ export interface LastUpdatedOptions {
* @default
* { dateStyle: 'short', timeStyle: 'short' }
*/
formatOptions?: Intl.DateTimeFormatOptions
formatOptions?: Intl.DateTimeFormatOptions & { forceLocale?: boolean }
}
```

Expand Down
Expand Up @@ -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)
Expand All @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion types/default-theme.d.ts
Expand Up @@ -435,7 +435,7 @@ export namespace DefaultTheme {
* @default
* { dateStyle: 'short', timeStyle: 'short' }
*/
formatOptions?: Intl.DateTimeFormatOptions
formatOptions?: Intl.DateTimeFormatOptions & { forceLocale?: boolean }
}

// not found -----------------------------------------------------------------
Expand Down

0 comments on commit a18e5e4

Please sign in to comment.