--- import CategoryBadge from './CategoryBadge.astro'; export interface Props { items: any[]; showCount?: boolean; type: 'latest' | 'category' | 'author' | 'tag'; slug?: string; pageInfo?: { hasNextPage: boolean; endCursor: string | null; }; gridColumns?: 3 | 4; } const { items = [], showCount = false, type = 'latest', slug = '', pageInfo = { hasNextPage: false, endCursor: null }, gridColumns = 4 } = Astro.props; // Конфиг для клиентского скрипта const loadMoreConfig = { type, slug, gridColumns }; function getCoauthorsNames(coauthors: any[]): string { if (!coauthors || coauthors.length === 0) return ''; return coauthors .map((coauthor: any) => { const name = coauthor?.node?.name || coauthor?.name; return name; }) .filter(Boolean) .join(', '); } function shouldBeLarge(index: number, columns: number): boolean { if (columns === 4) { // Паттерн для 4 колонок: большие на позициях 8, 19, 30, 41... if (index < 8) return false; return (index - 8) % 11 === 0; } else { // Паттерн для 3 колонок: большие на позициях 6, 14, 22, 30... if (index < 6) return false; return (index - 6) % 8 === 0; } } ---
{showCount && items.length > 0 && (

Все статьи ({items.length})

)}
{items.map((item, index) => { const postUrl = item.uri || `/blog/${item.databaseId}`; const postDate = new Date(item.date); const isLarge = shouldBeLarge(index, gridColumns); return (
{item.featuredImage?.node?.sourceUrl ? ( {item.featuredImage.node.altText ) : (
)} {item.categories?.nodes?.[0] && ( )}
{item.coauthors && item.coauthors.length > 0 && ( )}

); })}
{pageInfo.hasNextPage && (
)}