import dayjs from 'dayjs' import Image from 'next/image' import Link from 'next/link' import authors from '@/lib/authors.json' import type Author from '@/types/author' import type PostTypes from '@/types/post' interface Props { post: PostTypes } const BlogGridItem = ({ post }: Props) => { const authorArray: string[] | undefined = post.author ? post.author.split(',') : [] const author = [] if (authorArray) { for (let i = 0; i < authorArray.length; i++) { author.push( authors.find((authors: Author) => { return authors.author_id === authorArray[i] }) ) } } const resolveImagePath = (img: string | undefined): string | null => { if (!img) return null return img.startsWith('/') || img.startsWith('http') ? img : `/images/blog/${img}` } const imageUrl = resolveImagePath(post.imgThumb) || resolveImagePath(post.imgSocial) || '/images/blog/blog-placeholder.png' return (
{`${post.title}
{post.date && (

{dayjs(post.date).format('D MMM YYYY')}

{post.readingTime && ( <>

•

{post.readingTime}

)}
)}

{post.title}

{post.description}

) } export default BlogGridItem