feat: show recipe image on page

This commit is contained in:
Max Richter
2025-10-22 16:24:04 +02:00
parent 3b3baca679
commit bd7dde2391
5 changed files with 27 additions and 16 deletions

View File

@@ -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://")) {

View File

@@ -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}`;
}