summaryrefslogtreecommitdiffstats
path: root/src/components/Widgets/RecentPosts/RecentPosts.tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-01-29 18:21:37 +0100
committerArmand Philippot <git@armandphilippot.com>2022-01-29 19:02:57 +0100
commite4d5b8151802517b2943756fc0d09ffa95e2c4e2 (patch)
tree9e99137a7b64ea7993a8311a7162336a551be8b2 /src/components/Widgets/RecentPosts/RecentPosts.tsx
parent47b854de26dea24e7838fd0804df103dee99635f (diff)
chore: replace lingui functions with react-intl
Diffstat (limited to 'src/components/Widgets/RecentPosts/RecentPosts.tsx')
-rw-r--r--src/components/Widgets/RecentPosts/RecentPosts.tsx16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/components/Widgets/RecentPosts/RecentPosts.tsx b/src/components/Widgets/RecentPosts/RecentPosts.tsx
index 8022bff..08ce7e4 100644
--- a/src/components/Widgets/RecentPosts/RecentPosts.tsx
+++ b/src/components/Widgets/RecentPosts/RecentPosts.tsx
@@ -1,16 +1,17 @@
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';
+import { useIntl } from 'react-intl';
import useSWR from 'swr';
import styles from './RecentPosts.module.scss';
const RecentPosts = () => {
+ const intl = useIntl();
const { data, error } = useSWR('/recent-posts', () =>
getPublishedPosts({ first: 3 })
);
@@ -36,7 +37,12 @@ const RecentPosts = () => {
)}
<h3 className={styles.title}>{post.title}</h3>
<dl className={styles.meta}>
- <dt>{t`Published on:`}</dt>
+ <dt>
+ {intl.formatMessage({
+ defaultMessage: 'Published on:',
+ description: 'RecentPosts: publication date label',
+ })}
+ </dt>
<dd>
<time dateTime={post.dates.publication}>
{getFormattedDate(post.dates.publication, locale)}
@@ -51,7 +57,11 @@ const RecentPosts = () => {
};
const getPostsItems = () => {
- if (error) return t`Failed to load.`;
+ if (error)
+ return intl.formatMessage({
+ defaultMessage: 'Failed to load.',
+ description: 'RecentPosts: failed to load text',
+ });
if (!data) return <Spinner />;
return data.posts.map((post) => getPost(post));