From b9c1953c79688fc3f536b7927692309c9780b5da Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Thu, 6 Jan 2022 17:55:24 +0100
Subject: refactor: reuse PostMeta components on single articles/pages

---
 src/components/PostPreview/PostPreview.tsx | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

(limited to 'src/components/PostPreview/PostPreview.tsx')

diff --git a/src/components/PostPreview/PostPreview.tsx b/src/components/PostPreview/PostPreview.tsx
index ccbb9e5..fa8bfd0 100644
--- a/src/components/PostPreview/PostPreview.tsx
+++ b/src/components/PostPreview/PostPreview.tsx
@@ -1,6 +1,6 @@
 import PostMeta from '@components/PostMeta/PostMeta';
 import { t } from '@lingui/macro';
-import { ArticlePreview } from '@ts/types/articles';
+import { ArticleMeta, ArticlePreview } from '@ts/types/articles';
 import Link from 'next/link';
 import styles from './PostPreview.module.scss';
 import Image from 'next/image';
@@ -18,6 +18,12 @@ const PostPreview = ({
 }) => {
   const TitleTag = `h${titleLevel}` as keyof JSX.IntrinsicElements;
 
+  const meta: ArticleMeta = {
+    commentCount: post.commentCount ? post.commentCount : 0,
+    dates: post.dates,
+    thematics: post.thematics,
+  };
+
   return (
     <article className={styles.wrapper}>
       {post.featuredImage && Object.keys(post.featuredImage).length > 0 && (
@@ -55,12 +61,7 @@ const PostPreview = ({
           <ArrowIcon />
         </ButtonLink>
       </footer>
-      <PostMeta
-        commentCount={post.commentCount}
-        publicationDate={post.dates.publication}
-        updateDate={post.dates.update}
-        thematics={post.thematics}
-      />
+      <PostMeta meta={meta} />
     </article>
   );
 };
-- 
cgit v1.2.3

