Skip to content

Commit

Permalink
fix(theme): 文件未添加到git时最后更新时间计算错误
Browse files Browse the repository at this point in the history
  • Loading branch information
pengzhanbo committed Mar 28, 2024
1 parent c2fc5ad commit c554001
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion theme/src/client/components/Page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ onContentUpdated(() => zoom?.refresh())
@media (min-width: 1440px) {
.plume-page:not(.has-sidebar) .content {
max-width: 784px;
max-width: 884px;
}
.plume-page:not(.has-sidebar) .container {
Expand Down
20 changes: 11 additions & 9 deletions theme/src/client/composables/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ export function useLastUpdated() {
const frontmatter = usePageFrontmatter<PlumeThemePageFrontmatter>()
const lang = usePageLang()

const date = computed(() => new Date(page.value.git?.updatedTime ?? ''))
const isoDatetime = computed(() => date.value.toISOString())
const date = computed(() => page.value.git?.updatedTime ? new Date(page.value.git.updatedTime) : null)
const isoDatetime = computed(() => date.value?.toISOString())

const datetime = ref('')

Expand All @@ -76,13 +76,15 @@ export function useLastUpdated() {
if (frontmatter.value.lastUpdated === false || theme.value.lastUpdated === false)
return

datetime.value = new Intl.DateTimeFormat(
theme.value.lastUpdated?.formatOptions?.forceLocale ? lang.value : undefined,
theme.value.lastUpdated?.formatOptions ?? {
dateStyle: 'short',
timeStyle: 'short',
},
).format(date.value)
datetime.value = date.value
? new Intl.DateTimeFormat(
theme.value.lastUpdated?.formatOptions?.forceLocale ? lang.value : undefined,
theme.value.lastUpdated?.formatOptions ?? {
dateStyle: 'short',
timeStyle: 'short',
},
).format(date.value)
: ''
})
})

Expand Down

0 comments on commit c554001

Please sign in to comment.