This is an automated email from the ASF dual-hosted git repository.
tuhaihe pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry-site.git
The following commit(s) were added to refs/heads/main by this push:
new e433d50242 Fix: make blog display the correct blog date
e433d50242 is described below
commit e433d50242753a6c67efd95bd2d4f41d9f2f1084
Author: Dianjin Wang <[email protected]>
AuthorDate: Mon Jul 20 14:20:12 2026 +0800
Fix: make blog display the correct blog date
After upgrading to Docusaurus v3.10.2, the `formattedDate` field is no
longer available in `BlogPostMetadata`. The standard Docusaurus approach
uses `useDateTimeFormat()` from `@docusaurus/theme-common/internal` to
format the raw `date` string.
---
src/theme/BlogPostItem/components/Authors/index.tsx | 11 +++++++++--
src/theme/BlogPostItem/components/Info/index.tsx | 17 ++++++++++++++---
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/src/theme/BlogPostItem/components/Authors/index.tsx
b/src/theme/BlogPostItem/components/Authors/index.tsx
index 272fc3f3bc..560d069217 100644
--- a/src/theme/BlogPostItem/components/Authors/index.tsx
+++ b/src/theme/BlogPostItem/components/Authors/index.tsx
@@ -1,12 +1,19 @@
import { useBlogPost } from "@docusaurus/plugin-content-blog/client";
+import { useDateTimeFormat } from "@docusaurus/theme-common/internal";
export default function BlogPostItemHeaderAuthors({
styles,
}: {
styles?: React.CSSProperties;
}): JSX.Element {
const {
- metadata: { authors, formattedDate },
+ metadata: { authors, date },
} = useBlogPost();
+ const dateTimeFormat = useDateTimeFormat({
+ day: "numeric",
+ month: "long",
+ year: "numeric",
+ timeZone: "UTC",
+ });
const authorsCount = authors.length;
if (authorsCount === 0) {
return null;
@@ -51,7 +58,7 @@ export default function BlogPostItemHeaderAuthors({
background: "var(--color-border-strong)",
}}
/>
- <span>{formattedDate}</span>
+ <span>{dateTimeFormat.format(new Date(date))}</span>
</div>
);
}
diff --git a/src/theme/BlogPostItem/components/Info/index.tsx
b/src/theme/BlogPostItem/components/Info/index.tsx
index c186b5f703..e64fbdfd5f 100644
--- a/src/theme/BlogPostItem/components/Info/index.tsx
+++ b/src/theme/BlogPostItem/components/Info/index.tsx
@@ -2,6 +2,7 @@ import React from "react";
import clsx from "clsx";
import { translate } from "@docusaurus/Translate";
import { usePluralForm } from "@docusaurus/theme-common";
+import { useDateTimeFormat } from "@docusaurus/theme-common/internal";
import { useBlogPost } from "@docusaurus/plugin-content-blog/client";
import type { Props } from "@theme/BlogPostItem/Header/Info";
@@ -30,7 +31,7 @@ function ReadingTime({ readingTime }: { readingTime: number
}) {
return <>{readingTimePlural(readingTime)}</>;
}
-function Date({
+function DateTime({
date,
formattedDate,
}: {
@@ -52,11 +53,21 @@ export default function BlogPostItemHeaderInfo({
className,
}: Props): JSX.Element {
const { metadata } = useBlogPost();
- const { date, formattedDate, readingTime } = metadata;
+ const { date, readingTime } = metadata;
+
+ const dateTimeFormat = useDateTimeFormat({
+ day: "numeric",
+ month: "long",
+ year: "numeric",
+ timeZone: "UTC",
+ });
+
+ const formatDate = (blogDate: string) =>
+ dateTimeFormat.format(new Date(blogDate));
return (
<div className={clsx(className)}>
- <Date date={date} formattedDate={formattedDate} />
+ <DateTime date={date} formattedDate={formatDate(date)} />
{typeof readingTime !== "undefined" && (
<>
<Spacer />
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]