feat: better glob matching featured images
This commit is contained in:
parent
06c523c667
commit
e0f8e02577
2 changed files with 2 additions and 2 deletions
|
@ -27,7 +27,7 @@ const authorInfo = authorData ? authorData.data : siteConfig.defaultAuthor;
|
|||
|
||||
// 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
|
||||
const featuredImages = import.meta.glob(`/src/content/posts/*/featured.*`,{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 matchedImage = Object.keys(featuredImages).find(path => path.includes(slug));
|
||||
let matchedImage_src;
|
||||
|
|
|
@ -75,7 +75,7 @@ async function getExternalImage(post) {
|
|||
return externalImageCache.get(post.slug);
|
||||
}
|
||||
|
||||
const featuredImages = import.meta.glob(`/src/content/posts/*/featured.*`, {import: 'default', eager: true});
|
||||
const featuredImages = import.meta.glob(`/src/content/posts/*/featured.{avif,png,jpg,jpeg,webp}`, {import: 'default', eager: true});
|
||||
const matchedImage = Object.keys(featuredImages).find(path => path.includes(post.slug));
|
||||
let matchedImage_;
|
||||
if (matchedImage) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue