import React from 'react' import { Link } from 'react-router-dom' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faCalendar, faUser, faNewspaper } from '@fortawesome/free-solid-svg-icons' import { formatDistance } from 'date-fns' import { BlogPostPreview } from '../services/exploreService' import { useEventModel } from 'applesauce-react/hooks' import { Models } from 'applesauce-core' interface BlogPostCardProps { post: BlogPostPreview href: string } const BlogPostCard: React.FC = ({ post, href }) => { const profile = useEventModel(Models.ProfileModel, [post.author]) const displayName = profile?.name || profile?.display_name || `${post.author.slice(0, 8)}...${post.author.slice(-4)}` const publishedDate = post.published || post.event.created_at const formattedDate = formatDistance(new Date(publishedDate * 1000), new Date(), { addSuffix: true }) return (
{post.image ? ( {post.title} ) : (
)}

{post.title}

{post.summary && (

{post.summary}

)}
{displayName} {formattedDate}
) } export default BlogPostCard