aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/Widgets/RecentPosts
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-01-25 15:53:43 +0100
committerArmand Philippot <git@armandphilippot.com>2022-01-25 16:28:39 +0100
commitf6e0e444820f67f212e362c54816df5d0e4d4cf0 (patch)
tree0f4fc539e66815b8f2ff1ad7d56a99e5aafa65cc /src/components/Widgets/RecentPosts
parent97dc68e22e754d8e478beee590dbe9868171af50 (diff)
chore: wrap dates with time tag
Diffstat (limited to 'src/components/Widgets/RecentPosts')
-rw-r--r--src/components/Widgets/RecentPosts/RecentPosts.tsx17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/components/Widgets/RecentPosts/RecentPosts.tsx b/src/components/Widgets/RecentPosts/RecentPosts.tsx
index 9c13aa2..8022bff 100644
--- a/src/components/Widgets/RecentPosts/RecentPosts.tsx
+++ b/src/components/Widgets/RecentPosts/RecentPosts.tsx
@@ -1,7 +1,9 @@
import Spinner from '@components/Spinner/Spinner';
+import { config } from '@config/website';
import { t } from '@lingui/macro';
import { getPublishedPosts } from '@services/graphql/queries';
import { ArticlePreview } from '@ts/types/articles';
+import { getFormattedDate } from '@utils/helpers/format';
import Image from 'next/image';
import Link from 'next/link';
import { useRouter } from 'next/router';
@@ -12,12 +14,8 @@ const RecentPosts = () => {
const { data, error } = useSWR('/recent-posts', () =>
getPublishedPosts({ first: 3 })
);
- const { locale } = useRouter();
- const dateOptions: Intl.DateTimeFormatOptions = {
- day: 'numeric',
- month: 'long',
- year: 'numeric',
- };
+ const router = useRouter();
+ const locale = router.locale ? router.locale : config.locales.defaultLocale;
const getPost = (post: ArticlePreview) => {
return (
@@ -40,10 +38,9 @@ const RecentPosts = () => {
<dl className={styles.meta}>
<dt>{t`Published on:`}</dt>
<dd>
- {new Date(post.dates.publication).toLocaleDateString(
- locale,
- dateOptions
- )}
+ <time dateTime={post.dates.publication}>
+ {getFormattedDate(post.dates.publication, locale)}
+ </time>
</dd>
</dl>
</article>