Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions components/ui/layout-grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import React, { useState } from "react";
import { AnimatePresence, motion } from "framer-motion";
import { cn } from "@/lib/utils";
import Image, { StaticImageData } from "next/image";
import Image, { getImageProps, StaticImageData } from "next/image";

type Card = {
id: number;
Expand Down Expand Up @@ -60,15 +60,22 @@ export const LayoutGrid = ({ cards }: { cards: Card[] }) => {
};

const ImageComponent = ({ card }: { card: Card }) => {
const { props: imageProps } = getImageProps({
src:
typeof card.thumbnail === "string" ? card.thumbnail : card.thumbnail.src,
alt: "thumbnail",
// TODO: It would be good to specifiy a proper sizes argument for the grid.
});
return (
<motion.img
layoutId={`image-${card.id}-image`}
src={typeof card.thumbnail === 'string' ? card.thumbnail : card.thumbnail.src} // Handle both types
srcSet={imageProps.srcSet} // Handle both types
src={imageProps.src} // Handle both types
height="500"
width="500"
className={cn(
"object-cover object-top inset-0 h-full w-full transition duration-200",
"md:absolute"
"md:absolute"
)}
alt="thumbnail"
/>
Expand Down