Merge pull request #315 from timlrx/fix/optional-proj-img

fix: allow proj img to be optional
This commit is contained in:
Timothy 2021-12-27 15:05:48 +08:00 committed by GitHub
commit e3d7630f6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,9 +3,23 @@ import Link from './Link'
const Card = ({ title, description, imgSrc, href }) => (
<div className="p-4 md:w-1/2 md" style={{ maxWidth: '544px' }}>
<div className="h-full overflow-hidden border-2 border-gray-200 rounded-md border-opacity-60 dark:border-gray-700">
{href ? (
<Link href={href} aria-label={`Link to ${title}`}>
<div
className={`${
imgSrc && 'h-full'
} overflow-hidden border-2 border-gray-200 rounded-md border-opacity-60 dark:border-gray-700`}
>
{imgSrc &&
(href ? (
<Link href={href} aria-label={`Link to ${title}`}>
<Image
alt={title}
src={imgSrc}
className="object-cover object-center lg:h-48 md:h-36"
width={544}
height={306}
/>
</Link>
) : (
<Image
alt={title}
src={imgSrc}
@ -13,16 +27,7 @@ const Card = ({ title, description, imgSrc, href }) => (
width={544}
height={306}
/>
</Link>
) : (
<Image
alt={title}
src={imgSrc}
className="object-cover object-center lg:h-48 md:h-36"
width={544}
height={306}
/>
)}
))}
<div className="p-6">
<h2 className="mb-3 text-2xl font-bold leading-8 tracking-tight">
{href ? (