Skip to content

Instantly share code, notes, and snippets.

@kjmczk
Created April 30, 2021 08:21
Show Gist options
  • Save kjmczk/ff08fd5e0428932df9dc142ff7d2daad to your computer and use it in GitHub Desktop.
Save kjmczk/ff08fd5e0428932df9dc142ff7d2daad to your computer and use it in GitHub Desktop.
components/Thumbnail.tsx - MDX Blog Simple - Medium
// 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