diff options
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; |
