fix: undefined while reading author data

This commit is contained in:
草师傅 2025-07-23 18:42:27 +08:00
parent cc238f8f2a
commit 4387aa1f6a
Signed by: gb
GPG key ID: 43330A030E2D6478

View file

@ -26,7 +26,7 @@ const slug = Astro.params.slug;
const author = Array.isArray(entry.data.author) ? entry.data.author : (entry.data.author !== undefined ? [entry.data.author] : [{collection: 'authors', id: siteConfig.defaultAuthor.id}]);
// Get author data
const authorData = await Promise.all((author).map((singleAuthor) => getEntry(singleAuthor).then(authorEntry => authorEntry.data)))
const authorData = await Promise.all((author).map((singleAuthor) => getEntry(singleAuthor).then(authorEntry => authorEntry?.data)))
const authorInfo = authorData.includes(undefined) ? [{data: siteConfig.defaultAuthor}] : authorData;
// get featured image and use it as og:image