This commit is contained in:
john 2025-05-04 00:29:02 +02:00
parent 62afad71d3
commit e29b68a907

View file

@ -0,0 +1,31 @@
import { Post } from '../model/posts/posts.ts'
interface PostItemProps {
post: Post
}
export default function PostItem({ post }: PostItemProps) {
const formattedDate = post.createdAt.toLocaleString('en-US', {
year: 'numeric',
month: 'short',
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
})
return (
<article className="w-full p-4" key={post.postId}>
<div className="text-sm text-gray-500 mb-3">{formattedDate}</div>
<div className="text-gray-800 mb-4 whitespace-pre-wrap">{post.content}</div>
{post.media.length > 0 && (
<div className="grid gap-4 grid-cols-1">
{post.media.map((src) => (
<img key={src} src={src} alt="" className="w-full h-auto" loading="lazy" />
))}
</div>
)}
</article>
)
}