A Astro blog hosted on Vercel

update loader for webp and convert pngs to webp

src/content/gallery/Fight.webp

This is a binary file and will not be displayed.

src/content/gallery/Michigan_in_the_Summer.png

This is a binary file and will not be displayed.

src/content/gallery/Michigan_in_the_Summer.webp

This is a binary file and will not be displayed.

src/content/gallery/Nightshade.webp

This is a binary file and will not be displayed.

src/content/gallery/Smile.webp

This is a binary file and will not be displayed.

src/content/gallery/The_Fallen_Bovine.webp

This is a binary file and will not be displayed.

src/content/gallery/Yado.webp

This is a binary file and will not be displayed.

+5 -5
src/utils/imageLoader.ts
··· 4 4 5 5 function image(fileName: string): Loader { 6 6 return { 7 - name: 'png', 7 + name: 'webp', 8 8 load: async ({ store, parseData, generateDigest }) => { 9 9 store.keys().forEach((id) => store.delete(id)); 10 10 11 - const directory = fs.readdirSync(fileName).filter((file) => file.endsWith(".png")); 11 + const directory = fs.readdirSync(fileName).filter((file) => file.endsWith(".webp")); 12 12 13 13 const images = await Promise.all( 14 14 directory.map(async (path) => { 15 15 const metadata = await exiftool.read(`${fileName}/${path}`); 16 16 17 - const title = metadata.Title; 18 - const artist = metadata.Artist; 19 - const alt = metadata.Description || metadata.ImageDescription; 17 + const title = metadata.Title ?? ""; 18 + const artist = metadata.Artist ?? ""; 19 + const alt = metadata.Description ?? metadata.ImageDescription ?? ""; 20 20 const width = metadata.ImageWidth; 21 21 const height = metadata.ImageHeight; 22 22