This commit is contained in:
@@ -13,16 +13,16 @@ interface Props {
|
|||||||
maxWidth?: number;
|
maxWidth?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function checkImage(src:string){
|
async function checkImage(src: string) {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(src);
|
const res = await fetch(src);
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
return src
|
return src;
|
||||||
}
|
}
|
||||||
return undefined
|
return undefined;
|
||||||
}catch(err){
|
} catch (err) {
|
||||||
console.log({src});
|
console.log({ src });
|
||||||
return undefined
|
return undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ const {
|
|||||||
|
|
||||||
let thumbhash = hash && image.fsPath ? await generateThumbHash(image) : "";
|
let thumbhash = hash && image.fsPath ? await generateThumbHash(image) : "";
|
||||||
|
|
||||||
const imageSrc = await checkImage(image);
|
const imageSrc = await checkImage(image.src);
|
||||||
|
|
||||||
let exif = await getExifData(image);
|
let exif = await getExifData(image);
|
||||||
|
|
||||||
@@ -60,21 +60,25 @@ const sizes = [
|
|||||||
].filter((size) => !maxWidth || size.width <= maxWidth);
|
].filter((size) => !maxWidth || size.width <= maxWidth);
|
||||||
---
|
---
|
||||||
|
|
||||||
{imageSrc?
|
{
|
||||||
<AstroImage
|
imageSrc ? (
|
||||||
src={imageSrc}
|
<AstroImage
|
||||||
alt={alt}
|
src={imageSrc}
|
||||||
data-thumbhash={thumbhash}
|
alt={alt}
|
||||||
data-exif={JSON.stringify(exif)}
|
data-thumbhash={thumbhash}
|
||||||
inferSize={true}
|
data-exif={JSON.stringify(exif)}
|
||||||
pictureAttributes={{
|
inferSize={true}
|
||||||
class: `${hash ? "block h-full relative" : ""} ${loader ? "thumb" : ""} ${pictureClass}`,
|
pictureAttributes={{
|
||||||
}}
|
class: `${hash ? "block h-full relative" : ""} ${loader ? "thumb" : ""} ${pictureClass}`,
|
||||||
class={Astro.props.class}
|
}}
|
||||||
widths={sizes.map((size) => size.width)}
|
class={Astro.props.class}
|
||||||
sizes={sizes
|
widths={sizes.map((size) => size.width)}
|
||||||
.map((size) => `${size.media || "100vw"} ${size.width}px`)
|
sizes={sizes
|
||||||
.join(", ")}>
|
.map((size) => `${size.media || "100vw"} ${size.width}px`)
|
||||||
<slot />
|
.join(", ")}>
|
||||||
</AstroImage>
|
<slot />
|
||||||
:undefined }
|
</AstroImage>
|
||||||
|
) : undefined
|
||||||
|
}
|
||||||
|
) : undefined
|
||||||
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
export async function listResource(id: string): Promise<any[]> {
|
export async function listResource(id: string): Promise<any[] | any> {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`https://marka.max-richter.dev/${id}`,
|
`https://marka.max-richter.dev/${id}`,
|
||||||
|
@@ -17,7 +17,7 @@ const recipes = await memorium.listResource("Recipes");
|
|||||||
id: recipe.name.replace(/\.md$/, ""),
|
id: recipe.name.replace(/\.md$/, ""),
|
||||||
data: {
|
data: {
|
||||||
cover: recipe.content?.image
|
cover: recipe.content?.image
|
||||||
? `http://localhost:8080/${recipe.content.image}`
|
? {src:`http://localhost:8080/${recipe.content.image}`}
|
||||||
: undefined,
|
: undefined,
|
||||||
title: recipe.name.replace(/\.md$/, ""),
|
title: recipe.name.replace(/\.md$/, ""),
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user