mirror of
https://github.com/runyanjake/cooking.git
synced 2026-03-26 01:43:17 -07:00
Placeholder image when no image provided for the recipe
This commit is contained in:
parent
6bbbb74e9a
commit
4cf3b526a1
@ -8,9 +8,9 @@ interface RecipeCardProps {
|
||||
|
||||
export default function RecipeCard({ recipe }: RecipeCardProps) {
|
||||
// Convert relative path to public URL
|
||||
const imageSrc = recipe.displayPhoto.startsWith('./')
|
||||
const imageSrc = recipe.displayPhoto && recipe.displayPhoto.startsWith('./')
|
||||
? `/recipes/${recipe.folderPath}/${recipe.displayPhoto.replace('./', '')}`.replace(/\\/g, '/')
|
||||
: recipe.displayPhoto;
|
||||
: recipe.displayPhoto || null;
|
||||
|
||||
return (
|
||||
<Link
|
||||
@ -19,6 +19,7 @@ export default function RecipeCard({ recipe }: RecipeCardProps) {
|
||||
aria-label={`View recipe: ${recipe.title}`}
|
||||
>
|
||||
<div className="aspect-video bg-gray-200 dark:bg-gray-700 relative overflow-hidden">
|
||||
{imageSrc ? (
|
||||
<Image
|
||||
src={imageSrc}
|
||||
alt={`${recipe.title} - Recipe photo`}
|
||||
@ -27,6 +28,11 @@ export default function RecipeCard({ recipe }: RecipeCardProps) {
|
||||
sizes="(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw"
|
||||
unoptimized
|
||||
/>
|
||||
) : (
|
||||
<div className="flex items-center justify-center h-full text-4xl text-gray-400 dark:text-gray-600">
|
||||
🍽️
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="p-4 space-y-2">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user