From 82702fbe2d0607e7ca8a02c878b2e79a21664b7c Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Tue, 25 Jan 2022 11:45:11 +0100
Subject: chore: display total found posts in page meta

---
 src/pages/recherche/index.tsx | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

(limited to 'src/pages/recherche/index.tsx')

diff --git a/src/pages/recherche/index.tsx b/src/pages/recherche/index.tsx
index 647d049..771bd3b 100644
--- a/src/pages/recherche/index.tsx
+++ b/src/pages/recherche/index.tsx
@@ -47,6 +47,11 @@ const Search: NextPageWithLayout = () => {
     getKey,
     getPublishedPosts
   );
+  const [totalPostsCount, setTotalPostsCount] = useState<number>(0);
+
+  useEffect(() => {
+    if (data) setTotalPostsCount(data[0].pageInfo.total);
+  }, [data]);
 
   const isLoadingInitialData = !data && !error;
   const isLoadingMore: boolean =
@@ -95,7 +100,7 @@ const Search: NextPageWithLayout = () => {
       <article
         className={`${styles.article} ${styles['article--no-comments']}`}
       >
-        <PostHeader title={title} />
+        <PostHeader title={title} meta={{ results: totalPostsCount }} />
         <div className={styles.body}>
           {getPostsList()}
           {hasNextPage && (
-- 
cgit v1.2.3

