Files
supanextail/components/blog/cover-image.tsx
Michael 8aede6e33e Blog V1 (functionnal)
Need to clean TS code / replace placeholders / Design V1 to-do
2022-01-17 21:59:55 +01:00

34 lines
687 B
TypeScript

import Image from 'next/image';
import Link from 'next/link';
type Properties = {
title: string;
src: string;
slug?: string;
};
const CoverImage = ({ title, src, slug }: Properties): JSX.Element => {
const image = (
<Image
src={src}
alt={`Cover Image for ${title}`}
layout="fill"
objectFit="contain"
objectPosition={'center top'}
/>
);
return (
<div className="sm:mx-0 flex justify-center relative max-w-2xl h-48">
{slug ? (
<Link as={`/posts/${slug}`} href="/posts/[slug]">
<a aria-label={title}>{image}</a>
</Link>
) : (
image
)}
</div>
);
};
export default CoverImage;