article card uses next link

This commit is contained in:
tmshv committed 2020-02-18 20:35:16 +03:00
1 parent 0b47b12d27
commit 93d9021ac0
1 file changed
+25 -22
+25 -22
View File
@@ -3,6 +3,7 @@ import './styles.css'
import cx from 'classnames'
import { Date } from './Date'
import { IImage } from 'src/types'
import Link from 'next/link'
export interface IArticleCardProps {
article: any
@@ -11,29 +12,31 @@ export interface IArticleCardProps {
export const ArticleCard: React.FC<IArticleCardProps> = ({ article, ...props }) => (
<section className="ArticleCard">
<a className="invisible" href={article.url}>
<div className="ArticleCard-image">
{!props.preview ? null : (
<picture>
<img
className={cx({ opa: false })}
alt={props.preview.alt}
src={props.preview.src}
srcSet={props.preview.srcSet.map(({ url, density }) => `${url} ${density}x`).join(' ')}
/>
</picture >
)}
</div>
<Link href={article.url}>
<a className="invisible">
<div className="ArticleCard-image">
{!props.preview ? null : (
<picture>
<img
className={cx({ opa: false })}
alt={props.preview.alt}
src={props.preview.src}
srcSet={props.preview.srcSet.map(({ url, density }) => `${url} ${density}x`).join(' ')}
/>
</picture >
)}
</div>
<div className="ArticleCard-body">
{article.title}
<div className="ArticleCard-body">
{article.title}
{!article.date ? null : (
<Date>
{article.date}
</Date>
)}
</div>
</a>
{!article.date ? null : (
<Date>
{article.date}
</Date>
)}
</div>
</a>
</Link>
</section>
)