aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/PostPreview
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-01-06 17:55:24 +0100
committerArmand Philippot <git@armandphilippot.com>2022-01-06 18:14:42 +0100
commitb9c1953c79688fc3f536b7927692309c9780b5da (patch)
tree673a26c0b0a9cc587f89d1eea9af739c3f17daf2 /src/components/PostPreview
parent544f8cd400f888464a18ee30836f63d4b93a0822 (diff)
refactor: reuse PostMeta components on single articles/pages
Diffstat (limited to 'src/components/PostPreview')
-rw-r--r--src/components/PostPreview/PostPreview.tsx15
1 files changed, 8 insertions, 7 deletions
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>
);
};