Skip to content

Commit

Permalink
Fix dates in the blog (#335)
Browse files Browse the repository at this point in the history
  • Loading branch information
serras authored Oct 3, 2024
1 parent 430ac98 commit dea3674
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/components/Blog/BlogListPage/BlogListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import data from './blog-list-page.yml';
import styles from './blog-list-page.module.css';

const formatSubtitle = (name: string | undefined, date: string): string =>
name ? `${name}, ${date}` : `${date}`;
name ? `${name}, ${new Date(date).toDateString()}` : `${new Date(date).toDateString()}`;

function BlogListPageMetadata(props: Props): JSX.Element {
const { metadata } = props;
Expand All @@ -45,7 +45,7 @@ function BlogListPageContent(props: Props): JSX.Element {
title: item.content.metadata.title,
subtitle: formatSubtitle(
item.content.metadata.authors[0]?.name,
item.content.metadata.formattedDate,
item.content.metadata.date,
),
image: item.content.frontMatter.image,
body: item.content.metadata.description,
Expand Down
6 changes: 3 additions & 3 deletions src/theme/BlogPostItem/Header/Info/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function ReadingTime({ readingTime }: { readingTime: number }) {
return <>{readingTimePlural(readingTime)}</>;
}

function Date({
function DateInfo({
date,
formattedDate,
}: {
Expand All @@ -45,7 +45,7 @@ function Date({
}) {
return (
<time dateTime={date} itemProp="datePublished">
{formattedDate}
{new Date(date).toDateString()}
</time>
);
}
Expand Down Expand Up @@ -73,7 +73,7 @@ export default function BlogPostItemHeaderInfo({
<Spacer />
</>
)}
<Date date={date} formattedDate={formattedDate} />
<DateInfo date={date} formattedDate={formattedDate} />
{typeof readingTime !== 'undefined' && (
<>
<Spacer />
Expand Down

0 comments on commit dea3674

Please sign in to comment.