import dayjs from 'dayjs' import Link from 'next/link' import React from 'react' import { Badge } from 'ui' import AuthorAvatars from './AuthorAvatars' import blogAuthors from '@/lib/authors.json' import type PostTypes from '@/types/post' interface Props { post: PostTypes } const getAuthors = (post: PostTypes) => { const authorArray = post.author?.split(',').map((a) => a.trim()) || [] const authors = [] for (let i = 0; i < authorArray.length; i++) { const foundAuthor = blogAuthors.find((authors: any) => { return authors.author_id === authorArray[i] }) if (foundAuthor) { authors.push(foundAuthor) } } return authors } const BlogListItem = ({ post }: Props) => { const authors = getAuthors(post) const sanitizeCategory = (category: string) => category.replaceAll('-', ' ') return (

{post.title}

{post.categories && (
{post.categories.map( (category, i) => i === 0 && ( {sanitizeCategory(category)} ) )}
)} {post.date && (

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

)}
) } export default BlogListItem