diff --git a/src/components/comment/CommentItem.astro b/src/components/comment/CommentItem.astro index 5612bb9..7227bfc 100644 --- a/src/components/comment/CommentItem.astro +++ b/src/components/comment/CommentItem.astro @@ -50,7 +50,7 @@ const { comment, depth, pending } = Astro.props; {pending &&

您的评论正在等待审核中...

} diff --git a/src/helpers/formatter.ts b/src/helpers/formatter.ts index 1e5eaf6..0588710 100644 --- a/src/helpers/formatter.ts +++ b/src/helpers/formatter.ts @@ -61,7 +61,10 @@ export const formatShowDate = (date: Date) => { .toFormat(options.settings.timeFormat); }; -export const formatLocalDate = (source: string) => { +export const formatLocalDate = (source: string | Date, format?: string) => { const date = new Date(source); - return DateTime.fromJSDate(date).setLocale(options.settings.locale).toFormat(options.settings.timeFormat); + return DateTime.fromJSDate(date) + .setZone(options.settings.timeZone) + .setLocale(options.settings.locale) + .toFormat(format || options.settings.timeFormat); }; diff --git a/src/layouts/PostLayout.astro b/src/layouts/PostLayout.astro index 1ea5a79..cad7edf 100644 --- a/src/layouts/PostLayout.astro +++ b/src/layouts/PostLayout.astro @@ -7,7 +7,7 @@ import PostMeta from '@/components/meta/PostMeta.astro'; import TableOfContents from '@/components/page/toc/TableOfContents.astro'; import MusicPlayer from '@/components/player/MusicPlayer.astro'; import Sidebar from '@/components/sidebar/Sidebar.astro'; -import { formatShowDate } from '@/helpers/formatter'; +import { formatLocalDate } from '@/helpers/formatter'; import { getTag, posts, tags, type Post } from '@/helpers/schema'; import { urlJoin } from '@/helpers/tools'; import BaseLayout from '@/layouts/BaseLayout.astro'; @@ -39,7 +39,7 @@ const { Content, headings } = await post.render();

{post.title}

- + { post.tags.length > 0 && post.tags