From f6e0e444820f67f212e362c54816df5d0e4d4cf0 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Tue, 25 Jan 2022 15:53:43 +0100 Subject: chore: wrap dates with time tag --- src/components/ProjectSummary/ProjectSummary.tsx | 45 +++++++++++++----------- 1 file changed, 24 insertions(+), 21 deletions(-) (limited to 'src/components/ProjectSummary/ProjectSummary.tsx') diff --git a/src/components/ProjectSummary/ProjectSummary.tsx b/src/components/ProjectSummary/ProjectSummary.tsx index 5a4f9c8..1b07eb1 100644 --- a/src/components/ProjectSummary/ProjectSummary.tsx +++ b/src/components/ProjectSummary/ProjectSummary.tsx @@ -1,7 +1,9 @@ import GithubIcon from '@assets/images/social-media/github.svg'; import GitlabIcon from '@assets/images/social-media/gitlab.svg'; +import { config } from '@config/website'; import { t } from '@lingui/macro'; import { ProjectMeta } from '@ts/types/app'; +import { getFormattedDate } from '@utils/helpers/format'; import { slugify } from '@utils/helpers/slugify'; import useGithubApi from '@utils/hooks/useGithubApi'; import Image from 'next/image'; @@ -18,40 +20,41 @@ const ProjectSummary = ({ meta: ProjectMeta; }) => { const { license, repos, technologies } = meta; - const { locale } = useRouter(); + const router = useRouter(); + const locale = router.locale ? router.locale : config.locales.defaultLocale; const { data } = useGithubApi(repos?.github ? repos.github : ''); - const getFormattedDate = (date: string) => { - const dateOptions: Intl.DateTimeFormatOptions = { - day: 'numeric', - month: 'long', - year: 'numeric', - }; - - return new Date(date).toLocaleDateString(locale, dateOptions); - }; - return (
-
- {t`${title} -
+ {cover && ( +
+ {t`${title} +
+ )}
{data && (
{t`Created on`}
-
{t`${getFormattedDate(data.created_at)}`}
+
+ +
)} {data && (
{t`Last updated on`}
-
{t`${getFormattedDate(data.updated_at)}`}
+
+ +
)}
-- cgit v1.2.3