2022-10-17 23:37:01 +08:00
|
|
|
import Image from './Image';
|
|
|
|
import Link from './Link';
|
2022-07-17 21:40:41 +08:00
|
|
|
|
|
|
|
const Card = ({ title, description, imgSrc, href }) => (
|
|
|
|
<div className="md p-4 md:w-1/2" style={{ maxWidth: '544px' }}>
|
|
|
|
<div
|
|
|
|
className={`${
|
|
|
|
imgSrc && 'h-full'
|
2022-10-17 23:37:01 +08:00
|
|
|
} overflow-hidden rounded-md border-2 border-gray-200 border-opacity-60 dark:border-gray-700`}>
|
2022-07-17 21:40:41 +08:00
|
|
|
{imgSrc &&
|
|
|
|
(href ? (
|
|
|
|
<Link href={href} aria-label={`Link to ${title}`}>
|
|
|
|
<Image
|
|
|
|
alt={title}
|
|
|
|
src={imgSrc}
|
|
|
|
className="object-cover object-center md:h-36 lg:h-48"
|
|
|
|
width={544}
|
|
|
|
height={306}
|
|
|
|
/>
|
|
|
|
</Link>
|
|
|
|
) : (
|
|
|
|
<Image
|
|
|
|
alt={title}
|
|
|
|
src={imgSrc}
|
|
|
|
className="object-cover object-center md:h-36 lg:h-48"
|
|
|
|
width={544}
|
|
|
|
height={306}
|
|
|
|
/>
|
|
|
|
))}
|
|
|
|
<div className="p-6">
|
|
|
|
<h2 className="mb-3 text-2xl font-bold leading-8 tracking-tight">
|
|
|
|
{href ? (
|
|
|
|
<Link href={href} aria-label={`Link to ${title}`}>
|
|
|
|
{title}
|
|
|
|
</Link>
|
|
|
|
) : (
|
|
|
|
title
|
|
|
|
)}
|
|
|
|
</h2>
|
2022-10-17 23:37:01 +08:00
|
|
|
<p className="prose mb-3 max-w-none text-gray-500 dark:text-gray-400">
|
|
|
|
{description}
|
|
|
|
</p>
|
2022-07-17 21:40:41 +08:00
|
|
|
{href && (
|
|
|
|
<Link
|
|
|
|
href={href}
|
|
|
|
className="text-base font-medium leading-6 text-primary-500 hover:text-primary-600 dark:hover:text-primary-400"
|
2022-10-17 23:37:01 +08:00
|
|
|
aria-label={`Link to ${title}`}>
|
2022-07-17 21:40:41 +08:00
|
|
|
Learn more →
|
|
|
|
</Link>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-10-17 23:37:01 +08:00
|
|
|
);
|
2022-07-17 21:40:41 +08:00
|
|
|
|
2022-10-17 23:37:01 +08:00
|
|
|
export default Card;
|