fix: some type errors
Some checks failed
Deploy to SFTP Server / build (push) Failing after 6m48s

This commit is contained in:
Max Richter
2025-10-04 13:39:06 +02:00
parent 246fc3ae44
commit a1b8eb22e5
3 changed files with 31 additions and 27 deletions

View File

@@ -13,16 +13,16 @@ interface Props {
maxWidth?: number;
}
async function checkImage(src:string){
async function checkImage(src: string) {
try {
const res = await fetch(src);
if (res.ok) {
return src
return src;
}
return undefined
}catch(err){
console.log({src});
return undefined
return undefined;
} catch (err) {
console.log({ src });
return undefined;
}
}
@@ -37,7 +37,7 @@ const {
let thumbhash = hash && image.fsPath ? await generateThumbHash(image) : "";
const imageSrc = await checkImage(image);
const imageSrc = await checkImage(image.src);
let exif = await getExifData(image);
@@ -60,21 +60,25 @@ const sizes = [
].filter((size) => !maxWidth || size.width <= maxWidth);
---
{imageSrc?
<AstroImage
src={imageSrc}
alt={alt}
data-thumbhash={thumbhash}
data-exif={JSON.stringify(exif)}
inferSize={true}
pictureAttributes={{
class: `${hash ? "block h-full relative" : ""} ${loader ? "thumb" : ""} ${pictureClass}`,
}}
class={Astro.props.class}
widths={sizes.map((size) => size.width)}
sizes={sizes
.map((size) => `${size.media || "100vw"} ${size.width}px`)
.join(", ")}>
<slot />
</AstroImage>
:undefined }
{
imageSrc ? (
<AstroImage
src={imageSrc}
alt={alt}
data-thumbhash={thumbhash}
data-exif={JSON.stringify(exif)}
inferSize={true}
pictureAttributes={{
class: `${hash ? "block h-full relative" : ""} ${loader ? "thumb" : ""} ${pictureClass}`,
}}
class={Astro.props.class}
widths={sizes.map((size) => size.width)}
sizes={sizes
.map((size) => `${size.media || "100vw"} ${size.width}px`)
.join(", ")}>
<slot />
</AstroImage>
) : undefined
}
) : undefined
}

View File

@@ -1,4 +1,4 @@
export async function listResource(id: string): Promise<any[]> {
export async function listResource(id: string): Promise<any[] | any> {
try {
const response = await fetch(
`https://marka.max-richter.dev/${id}`,

View File

@@ -17,7 +17,7 @@ const recipes = await memorium.listResource("Recipes");
id: recipe.name.replace(/\.md$/, ""),
data: {
cover: recipe.content?.image
? `http://localhost:8080/${recipe.content.image}`
? {src:`http://localhost:8080/${recipe.content.image}`}
: undefined,
title: recipe.name.replace(/\.md$/, ""),
},