diff options
| author | Armand Philippot <git@armandphilippot.com> | 2021-12-16 18:22:08 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2021-12-16 18:22:08 +0100 |
| commit | 0ef4f77954ba54b52b96c70a8bffe96804bd222d (patch) | |
| tree | 7fe68b05271625f72f750786e1a94b71942d2cd5 /src/components/PostPreview/PostPreview.tsx | |
| parent | a4f865224e0e395c7e29bb3b7279a5101b554d2c (diff) | |
chore: display featuredImage and meta on posts list
Diffstat (limited to 'src/components/PostPreview/PostPreview.tsx')
| -rw-r--r-- | src/components/PostPreview/PostPreview.tsx | 61 |
1 files changed, 61 insertions, 0 deletions
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; |
