import Link from 'next/link' import type { Post, Tag } from '@/payload-types' interface PostPreviewProps { post: Post number: number className?: string } function formatDate(dateStr: string): string { const date = new Date(dateStr) const y = date.getFullYear() const m = String(date.getMonth() + 1).padStart(2, '0') const d = String(date.getDate()).padStart(2, '0') return `${y}.${m}.${d}` } export function PostPreview({ post, number, className }: PostPreviewProps) { const { title, slug, publishDate, excerpt, tags } = post const paddedNumber = String(number).padStart(3, '0') const formattedDate = publishDate ? formatDate(publishDate) : '' // Only show tags when depth=1 returns Tag objects (not bare IDs) const resolvedTags: Tag[] = Array.isArray(tags) ? tags.filter((t): t is Tag => typeof t === 'object' && t !== null) : [] const topTags = resolvedTags.slice(0, 3) return (
  • {paddedNumber} {formattedDate}
    {formattedDate}

    {title}

    {excerpt && (

    {excerpt}

    )} {topTags.length > 0 && (
    {topTags.map((tag, i) => ( {i > 0 && ·} {tag.name} ))}
    )}
    →
  • ) }