import { Card } from "@components/Card.tsx";
import { Recipe } from "@lib/recipes.ts";

export function RecipeCard({ recipe }: { recipe: Recipe }) {
  const { meta: { image = "Recipes/images/placeholder.jpg" } = {} } = recipe;

  const imageUrl = image.startsWith("Recipes/images/")
    ? `/api/images?image=${image}&width=200&height=200`
    : image;

  return (
    <Card
      title={recipe.name}
      image={imageUrl}
      link={`/recipes/${recipe.id}`}
    />
  );
}
