fix: article cover not displaying and potential errors

This commit is contained in:
草师傅 2025-08-19 21:17:02 +08:00
parent 81ddec2e15
commit 127e297e75
Signed by: gb
GPG key ID: 43330A030E2D6478

View file

@ -46,7 +46,7 @@ const authorInfo = authorData.includes(undefined) ? [{data: siteConfig.defaultA
// get featured image and use it as og:image // get featured image and use it as og:image
// use the custom cover image if it exists, otherwise use the featured image file in the same directory // use the custom cover image if it exists, otherwise use the featured image file in the same directory
const featuredImages = import.meta.glob(`/src/content/posts/*/featured.{avif,png,jpg,jpeg,webp}`,{import:'default',eager:true}); const featuredImages = import.meta.glob(`/src/content/posts/*/featured.{avif,png,jpg,jpeg,webp}`,{import:'default',eager:true});
const customFeaturedImage = entry.data.cover?.src const customFeaturedImage = entry.data.cover
const matchedImage = Object.keys(featuredImages).find(path => path.includes(slug)); const matchedImage = Object.keys(featuredImages).find(path => path.includes(slug));
let matchedImage_src; let matchedImage_src;
if (matchedImage && !customFeaturedImage) { if (matchedImage && !customFeaturedImage) {