diff --git a/src/components/BlogCard.astro b/src/components/BlogCard.astro index 8e83099..540d084 100644 --- a/src/components/BlogCard.astro +++ b/src/components/BlogCard.astro @@ -1,11 +1,10 @@ --- import type { CollectionEntry } from 'astro:content' -import { formatDate, readingTime } from '@lib/utils' +import { formatDate, readingTime, parseAuthors } from '@lib/utils' import { Image } from 'astro:assets' import { Badge } from '@/components/ui/badge' import { Separator } from '@/components/ui/separator' import Link from './Link.astro' -import { getEntry } from 'astro:content' type Props = { entry: CollectionEntry<'blog'> @@ -17,22 +16,7 @@ const { entry } = Astro.props as { const formattedDate = formatDate(entry.data.date) const readTime = readingTime(entry.body) - -let author = null -if ( - entry.data.author && - typeof entry.data.author === 'object' && - 'collection' in entry.data.author -) { - author = await getEntry(entry.data.author) -} else if (typeof entry.data.author === 'string') { - author = { - data: { - name: entry.data.author, - avatar: '/favicons/android-chrome-512x512.png', - }, - } -} +const authors = await parseAuthors(entry.data.author ?? []) ---