-
Notifications
You must be signed in to change notification settings - Fork 157
Expand file tree
/
Copy pathBlogPostItem.js
More file actions
32 lines (26 loc) · 963 Bytes
/
BlogPostItem.js
File metadata and controls
32 lines (26 loc) · 963 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import Link from "next/link";
export function BlogPostItem({ post }) {
const { title, date, excerpt, uri, featuredImage } = post ?? {};
return (
<article className='container max-w-4xl px-10 py-6 mx-auto rounded-lg shadow-sm bg-gray-50 mb-4'>
<time dateTime={date} className='text-sm text-gray-600'>
{new Date(date).toLocaleDateString("en-US", {
year: "numeric",
month: "long",
})}
</time>
{featuredImage && (
<img src={featuredImage?.node?.sourceUrl} alt='' className='w-full h-48 object-cover rounded-t-lg mt-2 mb-4' />
)}
<h2 className='mt-3'>
<Link href={uri} className='text-2xl font-bold hover:underline'>
{title}
</Link>
</h2>
<div className='mt-2 mb-4' dangerouslySetInnerHTML={{ __html: excerpt }} />
<Link href={uri} className='hover:underline text-orange-600 mt-4'>
Read more
</Link>
</article>
);
}