feat: cdn cutover

This commit is contained in:
Cory Dransfeldt 2024-04-12 17:26:17 -07:00
parent 57bd614e5d
commit 979d895f33
No known key found for this signature in database
20 changed files with 43 additions and 67 deletions

View file

@ -16,21 +16,15 @@ export const img = async (
alt = '',
className,
loading = 'lazy',
maxWidth = 1248,
sizes = '90vw',
formats = ['avif', 'webp', 'jpeg']
formats = ['avif', 'webp', 'jpg', 'jpeg']
) => {
const widths = [80, 200, 320, 570, 880, 1024, 1248].filter(width => width <= maxWidth);
const widths = [80, 200, 320, 570, 880, 1024, 1248];
const metadata = await Image(src, {
widths: [...widths],
formats: [...formats],
outputDir: './_site/assets/img/cache/',
urlPath: '/assets/img/cache/',
filenameFormat: (id, src, width, format, options) => {
const extension = path.extname(src);
const name = path.basename(src, extension);
return `${encodeURIComponent(name)}-${width}w.${format}`;
},
urlPath: '/assets/img/cache/'
});
const lowsrc = metadata.jpeg[metadata.jpeg.length - 1];