feat: trying to optimize builds
This commit is contained in:
@@ -12,6 +12,7 @@ interface Props {
|
||||
hash?: boolean;
|
||||
loader?: boolean;
|
||||
maxWidth?: number;
|
||||
thumbnail?: boolean;
|
||||
}
|
||||
|
||||
async function checkImage(image: ImageMetadata) {
|
||||
@@ -41,16 +42,17 @@ const {
|
||||
hash = true,
|
||||
alt,
|
||||
maxWidth,
|
||||
thumbnail = false,
|
||||
} = Astro.props;
|
||||
|
||||
|
||||
|
||||
const imageOk = await checkImage(image);
|
||||
const imageBuffer = imageOk && await getImageBuffer(image);
|
||||
const imageBuffer = imageOk && (await getImageBuffer(image));
|
||||
let thumbhash = imageBuffer && (await generateThumbHash(imageBuffer));
|
||||
let exif = imageBuffer && (await getExifData(imageBuffer));
|
||||
|
||||
const sizes = [
|
||||
const definedSizes = [
|
||||
{
|
||||
width: 240,
|
||||
media: "(max-width: 360px)",
|
||||
@@ -66,7 +68,11 @@ const sizes = [
|
||||
{
|
||||
width: image.width,
|
||||
},
|
||||
].filter((size) => !maxWidth || size.width <= maxWidth);
|
||||
];
|
||||
|
||||
const sizes = thumbnail
|
||||
? [definedSizes[0]]
|
||||
: definedSizes.filter((size) => !maxWidth || size.width <= maxWidth);
|
||||
---
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user