import Image from 'next/image' import { Tooltip, TooltipContent, TooltipTrigger } from 'ui' import type Author from '@/types/author' interface Props { authors: (Author | undefined)[] showName?: boolean size?: 'sm' | 'md' } const MAX_VISIBLE_AVATARS = 4 export default function AuthorAvatars({ authors, showName = true, size = 'sm' }: Props) { const valid = authors.filter(Boolean) as Author[] if (!valid.length) return null const px = size === 'md' ? 'w-6 h-6' : 'w-5 h-5' const visibleAvatars = valid.slice(0, MAX_VISIBLE_AVATARS) const allNames = valid.map((a) => a.author).join(', ') const nameLabel = valid.length > 2 ? `${valid[0].author}, +${valid.length - 1} other${valid.length - 1 > 1 ? 's' : ''}` : allNames const content = (
{nameLabel}
}