diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-10-12 17:24:13 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-11-11 18:14:41 +0100 |
| commit | 00f147a7a687d5772bcc538bc606cfff972178cd (patch) | |
| tree | 27eabeb83c05e14162c51b69d4a6f36d461947fc /src/pages/index.tsx | |
| parent | c87c615b5866b8a8f361eeb0764bfdea85740e90 (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.tsx | 15 |
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, |
