From 82702fbe2d0607e7ca8a02c878b2e79a21664b7c Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Tue, 25 Jan 2022 11:45:11 +0100 Subject: chore: display total found posts in page meta --- src/components/PostMeta/PostMeta.tsx | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'src/components/PostMeta') diff --git a/src/components/PostMeta/PostMeta.tsx b/src/components/PostMeta/PostMeta.tsx index 57c2ded..9aa67c7 100644 --- a/src/components/PostMeta/PostMeta.tsx +++ b/src/components/PostMeta/PostMeta.tsx @@ -1,4 +1,4 @@ -import { t } from '@lingui/macro'; +import { plural, t } from '@lingui/macro'; import { ArticleMeta } from '@ts/types/articles'; import Link from 'next/link'; import { useRouter } from 'next/router'; @@ -13,7 +13,8 @@ const PostMeta = ({ meta: ArticleMeta; mode?: PostMetaMode; }) => { - const { author, commentCount, dates, topics, thematics, website } = meta; + const { author, commentCount, dates, results, thematics, topics, website } = + meta; const { asPath, locale } = useRouter(); const isThematic = () => asPath.includes('/thematique/'); const isArticle = () => asPath.includes('/article/'); @@ -71,13 +72,13 @@ const PostMeta = ({
{author && (
-
{t`Written by`}
+
{t`Written by:`}
{author.name}
)} {dates && (
-
{t`Published on`}
+
{t`Published on:`}
{new Date(dates.publication).toLocaleDateString( locale, @@ -88,16 +89,28 @@ const PostMeta = ({ )} {dates && dates.publication !== dates.update && (
-
{t`Updated on`}
+
{t`Updated on:`}
{new Date(dates.update).toLocaleDateString(locale, dateOptions)}
)} + {results && ( +
+
{t`Total: `}
+
+ {plural(results, { + zero: '# articles', + one: '# article', + other: '# articles', + })} +
+
+ )} {!isThematic() && thematics && thematics.length > 0 && (
- {thematics.length > 1 ? t`Thematics` : t`Thematic`} + {thematics.length > 1 ? t`Thematics:` : t`Thematic:`}
{getThematics()}
@@ -105,14 +118,14 @@ const PostMeta = ({ {isThematic() && topics && topics.length > 0 && (
- {topics.length > 1 ? t`Topics` : t`Topic`} + {topics.length > 1 ? t`Topics:` : t`Topic:`}
{getTopics()}
)} {website && (
-
{t`Website`}
+
{t`Website:`}
{website}
@@ -120,7 +133,7 @@ const PostMeta = ({ )} {commentCount !== undefined && (
-
{t`Comments`}
+
{t`Comments:`}
{isArticle() ? ( {getCommentsCount()} -- cgit v1.2.3