diff --git a/src/components/Image.astro b/src/components/Image.astro index f0f4218..f69f8ba 100644 --- a/src/components/Image.astro +++ b/src/components/Image.astro @@ -16,6 +16,7 @@ interface Props { } async function checkImage(image: ImageMetadata) { +console.log("Checking image: ", image); const src = image.src; try { if (src.startsWith("/@fs") || src.startsWith("/_astro")) return true; diff --git a/src/helpers/image.ts b/src/helpers/image.ts index 0441ed4..ac4c53b 100644 --- a/src/helpers/image.ts +++ b/src/helpers/image.ts @@ -15,6 +15,8 @@ export async function generateThumbHash( const imagePath = (image as ImageMetadata & { fsPath: string }).fsPath ?? image.src; + if (!imagePath) return; + let sp; if (imagePath.startsWith("https://") || imagePath.startsWith("http://")) { const res = await fetch(imagePath); @@ -72,6 +74,8 @@ export async function getExifData(image: ImageMetadata) { const imagePath = (image as ImageMetadata & { fsPath: string }).fsPath ?? image.src; + if (!imagePath) return undefined; + try { let buffer: ArrayBuffer; if (imagePath.startsWith("https://") || imagePath.startsWith("http://")) { diff --git a/src/helpers/memorium.ts b/src/helpers/memorium.ts index 956f5cb..f3f820d 100644 --- a/src/helpers/memorium.ts +++ b/src/helpers/memorium.ts @@ -44,3 +44,16 @@ export async function listResource( return; } } + +export function getImageUrl(input: string): string { + if (!input) { + return; + } + if (input.startsWith("https://") || input.startsWith("http://")) { + return input; + } + if (input.startsWith("/")) { + return `https://marka.max-richter.dev${input}`; + } + return `https://marka.max-richter.dev/${input}`; +} diff --git a/src/pages/resources/[resourceType]/[resourceName].astro b/src/pages/resources/[resourceType]/[resourceName].astro index fdcd113..9e618f1 100644 --- a/src/pages/resources/[resourceType]/[resourceName].astro +++ b/src/pages/resources/[resourceType]/[resourceName].astro @@ -4,6 +4,7 @@ import { useTranslatedPath } from "@i18n/utils"; import * as memorium from "@helpers/memorium"; import { resources as resourceTypes } from "../resources.ts"; import markdownToText from "@helpers/markdownToText"; +import Image from "@components/Image.astro"; const { resourceType, resourceName } = Astro?.params; @@ -57,9 +58,13 @@ const instructions = resource?.content?.recipeInstructions || []; -
{resource?.content?.description}
-