diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-01-25 11:45:11 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-01-25 11:45:11 +0100 |
| commit | 82702fbe2d0607e7ca8a02c878b2e79a21664b7c (patch) | |
| tree | 2388abb10f8ec41ea4a20058f122cb0e7bcae9ef /src/pages/recherche | |
| parent | 958569e09071e4bb290f0ec120b4309ae5983d2d (diff) | |
chore: display total found posts in page meta
Diffstat (limited to 'src/pages/recherche')
| -rw-r--r-- | src/pages/recherche/index.tsx | 7 |
1 files changed, 6 insertions, 1 deletions
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 && ( |
