--- export interface Props { items: any[]; showCount?: boolean; } const { items = [], showCount = false, } = Astro.props; // Функция для извлечения класса цвета из строки function extractColorClass(colorString: string): string { if (!colorString) return 'bg-blue'; if (colorString.includes('фон меню:')) { const parts = colorString.split(':'); const color = parts[1]?.trim(); const validColors = [ 'black', 'yellow', 'blue', 'green', 'red', 'orange', 'gray', 'indigo', 'purple', 'pink', 'teal', 'cyan', 'white', 'gray-dark', 'light', 'dark' ]; if (color && validColors.includes(color)) { return `bg-${color}`; } } if (colorString.startsWith('bg-')) { return colorString; } const simpleColor = colorString.toLowerCase(); switch(simpleColor) { case 'black': case 'yellow': case 'blue': case 'green': case 'red': case 'orange': case 'gray': case 'indigo': case 'purple': case 'pink': case 'teal': case 'cyan': case 'white': case 'dark': case 'light': return `bg-${simpleColor}`; case 'gray-dark': return 'bg-gray-dark'; default: return 'bg-blue'; } } // Функция для получения списка имен соавторов function getCoauthorsNames(coauthors: any[]): string { if (!coauthors || coauthors.length === 0) return ''; return coauthors .map((coauthor: any) => coauthor?.node?.name || coauthor?.name) .filter(Boolean) .join(' '); } ---

{showCount && items.length > 0 && ( ({items.length}) )}

{items.map((item, index) => { const postUrl = item.uri || `/blog/${item.databaseId}`; const postDate = new Date(item.date); const coauthors = item.coauthors || []; const coauthorsNames = getCoauthorsNames(coauthors); const rawColor = item.categories?.nodes?.[0]?.color || ''; const categoryBgClass = extractColorClass(rawColor); let isLarge = false; let largePosition = ''; const rowNumber = Math.floor(index / 4) + 1; const positionInRow = index % 4; if (index >= 8) { const largeRowStart = (rowNumber - 3) % 3 === 0 && rowNumber >= 3; if (largeRowStart && positionInRow === 0) { isLarge = true; largePosition = 'first'; } } return ( ); })}