Created
April 30, 2021 08:21
-
-
Save kjmczk/ff08fd5e0428932df9dc142ff7d2daad to your computer and use it in GitHub Desktop.
components/Thumbnail.tsx - MDX Blog Simple - Medium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// components/Thumbnail.tsx | |
import Image from 'next/image'; | |
import Link from 'next/link'; | |
type Props = { | |
title: string; | |
src: string; | |
slug?: string; | |
}; | |
const Thumbnail: React.FC<Props> = ({ title, src, slug }: Props) => { | |
const image = ( | |
<Image | |
src={src} | |
alt={`Cover Image for ${title}`} | |
width={1280} | |
height={720} | |
/> | |
); | |
return ( | |
<> | |
{slug ? ( | |
<Link href={`/posts/${slug}`}> | |
<a aria-label={title}>{image}</a> | |
</Link> | |
) : ( | |
image | |
)} | |
</> | |
); | |
}; | |
export default Thumbnail; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment