diff --git a/src/components/Coauthors.astro b/src/components/Coauthors.astro new file mode 100644 index 0000000..629463f --- /dev/null +++ b/src/components/Coauthors.astro @@ -0,0 +1,200 @@ +--- +export interface Props { + coauthors: any[]; + prefix?: string; + className?: string; +} + +const { + coauthors = [], + prefix = '', + className = '', +} = Astro.props; + +function getAuthorUrl(coauthor: any): string { + if (coauthor?.url) return coauthor.url; + if (coauthor?.uri) return coauthor.uri; + if (coauthor?.databaseId) return `/author/${coauthor.databaseId}`; + return '#'; +} +--- + +{coauthors.length > 0 && ( +
+)} + + \ No newline at end of file diff --git a/src/components/ContentGrid.astro b/src/components/ContentGrid.astro index 850e06a..f9d50f0 100644 --- a/src/components/ContentGrid.astro +++ b/src/components/ContentGrid.astro @@ -6,19 +6,17 @@ export interface Props { const { items = [], - showCount = false, + 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(); - // Проверяем существование CSS класса const validColors = [ 'black', 'yellow', 'blue', 'green', 'red', 'orange', 'gray', 'indigo', 'purple', 'pink', 'teal', 'cyan', 'white', @@ -30,12 +28,10 @@ function extractColorClass(colorString: string): string { } } - // Если строка уже содержит "bg-" if (colorString.startsWith('bg-')) { return colorString; } - // Если это просто название цвета без префикса const simpleColor = colorString.toLowerCase(); switch(simpleColor) { case 'black': case 'yellow': case 'blue': case 'green': @@ -47,8 +43,17 @@ function extractColorClass(colorString: string): string { 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(' '); +} +---