import authors from 'lib/authors.json' import Image from 'next/image' import Link from 'next/link' import React from 'react' import type Author from '~/types/author' import type PostTypes from '~/types/post' import dayjs from 'dayjs' import { Badge } from 'ui' interface Props { post: PostTypes } const BlogListItem = ({ 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 sanitizeCategory = (category: string) => category.replaceAll('-', ' ') return (

{post.title}

{author.map((author: any, i: number) => { return (
{author.author_image_url && ( {`${author.author} )}
) })}
{post.categories && (
{post.categories.map( (category, i) => i === 0 && ( {sanitizeCategory(category)} ) )}
)} {post.date && (

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

)}
) } export default BlogListItem