fix: make some changes
This commit is contained in:
@@ -15,13 +15,15 @@ interface Props {
|
||||
|
||||
async function checkImage(src: string) {
|
||||
try {
|
||||
if (src.startsWith("/@fs") || src.startsWith("/_astro")) return true;
|
||||
const res = await fetch(src);
|
||||
if (res.ok) {
|
||||
return src;
|
||||
return true;
|
||||
}
|
||||
return undefined;
|
||||
return false;
|
||||
} catch (err) {
|
||||
return undefined;
|
||||
console.log("Failed to fetch: ",src);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,8 +37,7 @@ const {
|
||||
} = Astro.props;
|
||||
|
||||
let thumbhash = hash && image.fsPath ? await generateThumbHash(image) : "";
|
||||
|
||||
const imageSrc = await checkImage(image.src);
|
||||
const imageOk = await checkImage(image.src);
|
||||
|
||||
let exif = await getExifData(image);
|
||||
|
||||
@@ -60,9 +61,9 @@ const sizes = [
|
||||
---
|
||||
|
||||
{
|
||||
imageSrc ? (
|
||||
imageOk ? (
|
||||
<AstroImage
|
||||
src={imageSrc}
|
||||
src={image}
|
||||
alt={alt}
|
||||
data-thumbhash={thumbhash}
|
||||
data-exif={JSON.stringify(exif)}
|
||||
|
||||
Reference in New Issue
Block a user