From 0ef4f77954ba54b52b96c70a8bffe96804bd222d Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Thu, 16 Dec 2021 18:22:08 +0100
Subject: chore: display featuredImage and meta on posts list

---
 src/components/PostPreview/PostPreview.tsx | 61 ++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)
 create mode 100644 src/components/PostPreview/PostPreview.tsx

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

diff --git a/src/components/PostPreview/PostPreview.tsx b/src/components/PostPreview/PostPreview.tsx
new file mode 100644
index 0000000..8f3e0da
--- /dev/null
+++ b/src/components/PostPreview/PostPreview.tsx
@@ -0,0 +1,61 @@
+import PostMeta from '@components/PostMeta/PostMeta';
+import { t } from '@lingui/macro';
+import { ArticlePreview } from '@ts/types/articles';
+import Link from 'next/link';
+import ArrowRightIcon from '@assets/images/icon-arrow-right.svg';
+import styles from './PostPreview.module.scss';
+import Image from 'next/image';
+
+const PostPreview = ({
+  post,
+  TitleTag,
+}: {
+  post: ArticlePreview;
+  TitleTag: keyof JSX.IntrinsicElements;
+}) => {
+  return (
+    <article className={styles.wrapper}>
+      {post.featuredImage && (
+        <div className={styles.cover}>
+          <Image
+            src={post.featuredImage.sourceUrl}
+            alt={post.featuredImage.altText}
+            layout="fill"
+            objectFit="contain"
+          />
+        </div>
+      )}
+      <header className={styles.header}>
+        <TitleTag>
+          <Link href={`/article/${post.slug}`}>
+            <a>{post.title}</a>
+          </Link>
+        </TitleTag>
+      </header>
+      <div
+        className={styles.body}
+        dangerouslySetInnerHTML={{ __html: post.content }}
+      ></div>
+      <footer className={styles.footer}>
+        <Link href={post.slug}>
+          <a className={styles['read-more']}>
+            {t`Read more`}
+            <span className="screen-reader-text">
+              {' '}
+              {t({ message: `about ${post.title}`, comment: 'Post title' })}
+            </span>
+            <ArrowRightIcon className={styles.icon} />
+          </a>
+        </Link>
+      </footer>
+      <PostMeta
+        commentCount={post.commentCount}
+        publicationDate={post.date.publication}
+        updateDate={post.date.update}
+        thematics={post.thematics}
+      />
+    </article>
+  );
+};
+
+export default PostPreview;
-- 
cgit v1.2.3

