feat: load data from marka

This commit is contained in:
Max Richter
2025-10-04 13:07:11 +02:00
parent f84704d20b
commit fba2337b9c
11 changed files with 78 additions and 57 deletions

View File

@@ -13,6 +13,19 @@ interface Props {
maxWidth?: number;
}
async function checkImage(src:string){
try {
const res = await fetch(src);
if (res.ok) {
return src
}
return undefined
}catch(err){
console.log({src});
return undefined
}
}
const {
src: image,
loader = true,
@@ -24,6 +37,8 @@ const {
let thumbhash = hash && image.fsPath ? await generateThumbHash(image) : "";
const imageSrc = await checkImage(image);
let exif = await getExifData(image);
const sizes = [
@@ -45,11 +60,13 @@ const sizes = [
].filter((size) => !maxWidth || size.width <= maxWidth);
---
{imageSrc?
<AstroImage
src={image}
src={imageSrc}
alt={alt}
data-thumbhash={thumbhash}
data-exif={JSON.stringify(exif)}
inferSize={true}
pictureAttributes={{
class: `${hash ? "block h-full relative" : ""} ${loader ? "thumb" : ""} ${pictureClass}`,
}}
@@ -60,3 +77,4 @@ const sizes = [
.join(", ")}>
<slot />
</AstroImage>
:undefined }