import authors from 'lib/authors.json' import Image from 'next/image' import Link from 'next/link' import type PostTypes from 'types/post' // Extend PostTypes for CMS blog posts interface CMSPostTypes extends PostTypes { isCMS?: boolean authors?: Array<{ author: string author_id: string position: string author_url: string author_image_url: { url: string } username: string }> } function FeaturedThumb(blog: PostTypes | CMSPostTypes) { // First check if this is a CMS post if ('isCMS' in blog && blog.isCMS) { // For CMS posts, display author directly from the blog data const cmsBlog = blog as CMSPostTypes const author = cmsBlog.authors?.map((author) => ({ author: author.author || 'Unknown Author', author_image_url: author.author_image_url || null, author_url: author.author_url || '#', position: author.position || '', })) || [] return renderFeaturedThumb(blog, author) } // For static posts, look up author info from authors.json const authorArray = blog.author?.split(',').map((a) => a.trim()) || [] const author = [] for (let i = 0; i < authorArray.length; i++) { const foundAuthor = authors.find((authors: any) => { return authors.author_id === authorArray[i] }) if (foundAuthor) { author.push(foundAuthor) } } return renderFeaturedThumb(blog, author) } function renderFeaturedThumb(blog: PostTypes, author: any[]) { const imageUrl = blog.isCMS ? blog.thumb ? blog.thumb : blog.image ? blog.image : '/images/blog/blog-placeholder.png' : blog.thumb ? `/images/blog/${blog.thumb}` : blog.image ? `/images/blog/${blog.image}` : '/images/blog/blog-placeholder.png' return (
blog thumbnail
{blog.formattedDate} • {blog.readingTime}

{blog.title}

{blog.description}

{author.filter(Boolean).map((author: any, i: number) => { const authorImageUrl = typeof author.author_image_url === 'string' ? author.author_image_url : (author.author_image_url as { url: string })?.url || '' return (
{imageUrl && (
{`${author.author}
)}
{author.author}
) })}
) } export default FeaturedThumb