2023-07-30 18:27:45 +02:00
|
|
|
import { Card } from "@components/Card.tsx";
|
2023-08-01 17:50:00 +02:00
|
|
|
import { Recipe } from "@lib/resource/recipes.ts";
|
2023-08-06 17:47:26 +02:00
|
|
|
import { isLocalImage } from "@lib/string.ts";
|
2023-07-26 13:47:01 +02:00
|
|
|
|
|
|
|
export function RecipeCard({ recipe }: { recipe: Recipe }) {
|
2023-07-30 21:43:09 +02:00
|
|
|
const { meta: { image = "/placeholder.svg" } = {} } = recipe;
|
2023-07-30 18:27:45 +02:00
|
|
|
|
2023-08-06 17:47:26 +02:00
|
|
|
const imageUrl = isLocalImage(image)
|
2023-07-30 18:27:45 +02:00
|
|
|
? `/api/images?image=${image}&width=200&height=200`
|
|
|
|
: image;
|
|
|
|
|
2023-07-26 13:47:01 +02:00
|
|
|
return (
|
2023-07-30 18:27:45 +02:00
|
|
|
<Card
|
|
|
|
title={recipe.name}
|
|
|
|
image={imageUrl}
|
2023-08-11 16:13:20 +02:00
|
|
|
thumbnail={recipe?.meta?.thumbnail}
|
2023-07-30 18:27:45 +02:00
|
|
|
link={`/recipes/${recipe.id}`}
|
|
|
|
/>
|
2023-07-26 13:47:01 +02:00
|
|
|
);
|
|
|
|
}
|