aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages/index.tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-10-12 17:24:13 +0200
committerArmand Philippot <git@armandphilippot.com>2023-11-11 18:14:41 +0100
commit00f147a7a687d5772bcc538bc606cfff972178cd (patch)
tree27eabeb83c05e14162c51b69d4a6f36d461947fc /src/pages/index.tsx
parentc87c615b5866b8a8f361eeb0764bfdea85740e90 (diff)
feat(components): add a Time component
Instead of using helpers functions to format the date each time we need to use a time element, it makes more sense to create a new component dedicated to this task.
Diffstat (limited to 'src/pages/index.tsx')
-rw-r--r--src/pages/index.tsx15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/pages/index.tsx b/src/pages/index.tsx
index cdc51c5..fb6ba9a 100644
--- a/src/pages/index.tsx
+++ b/src/pages/index.tsx
@@ -21,17 +21,14 @@ import {
type SectionProps,
Heading,
Figure,
+ Time,
} from '../components';
import HomePageContent from '../content/pages/homepage.mdx';
import { getArticlesCard } from '../services/graphql';
import styles from '../styles/pages/home.module.scss';
import type { ArticleCard, NextPageWithLayout } from '../types';
import { PERSONAL_LINKS, ROUTES } from '../utils/constants';
-import {
- getFormattedDate,
- getSchemaJson,
- getWebPageSchema,
-} from '../utils/helpers';
+import { getSchemaJson, getWebPageSchema } from '../utils/helpers';
import { loadTranslation, type Messages } from '../utils/helpers/server';
import { useBreadcrumb, useSettings } from '../utils/hooks';
@@ -301,8 +298,6 @@ const HomePage: NextPageWithLayout<HomeProps> = ({ recentPosts }) => {
*/
const getRecentPosts = (): JSX.Element => {
const posts: CardsListItem[] = recentPosts.map((post) => {
- const isoDate = new Date(`${post.dates.publication}`).toISOString();
-
return {
cover: post.cover,
id: post.slug,
@@ -310,11 +305,7 @@ const HomePage: NextPageWithLayout<HomeProps> = ({ recentPosts }) => {
{
id: 'publication-date',
label: publicationDate,
- value: (
- <time dateTime={isoDate}>
- {getFormattedDate(post.dates.publication)}
- </time>
- ),
+ value: <Time date={post.dates.publication} />,
},
],
title: post.title,