feat: max image width option

This commit is contained in:
Cory Dransfeldt 2024-03-07 11:30:48 -08:00
parent 07738bc56e
commit 5dc95273ee
No known key found for this signature in database
3 changed files with 4 additions and 3 deletions

View file

@ -16,10 +16,11 @@ export const img = async (
alt = '',
className,
loading = 'lazy',
maxWidth = 1248,
sizes = '90vw',
formats = ['avif', 'webp', 'jpeg']
) => {
const widths = [320, 570, 880, 1024, 1248];
const widths = [320, 570, 880, 1024, 1248].filter(width => width <= maxWidth);
const metadata = await Image(src, {
widths: [...widths],
formats: [...formats],