feat: show recipe image on page
This commit is contained in:
@@ -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://")) {
|
||||
|
||||
@@ -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}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user