feat: upgrade to astro 5
This commit is contained in:
parent
47f21f8b3c
commit
0704481e0b
16 changed files with 3976 additions and 2671 deletions
27
src/lib/server-utils.ts
Normal file
27
src/lib/server-utils.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import { getEntry } from "astro:content"
|
||||
|
||||
export async function parseAuthors(authors: string[]) {
|
||||
if (!authors || authors.length === 0) return []
|
||||
|
||||
const parseAuthor = async (id: string) => {
|
||||
try {
|
||||
const author = await getEntry('authors', id)
|
||||
return {
|
||||
id,
|
||||
name: author?.data?.name || id,
|
||||
avatar: author?.data?.avatar || '/static/logo.png',
|
||||
isRegistered: !!author,
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error fetching author with id ${id}:`, error)
|
||||
return {
|
||||
id,
|
||||
name: id,
|
||||
avatar: '/static/logo.png',
|
||||
isRegistered: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return await Promise.all(authors.map(parseAuthor))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue