ig.rizaldy.club/components/Feed.js

43 lines
941 B
JavaScript
Raw Normal View History

2024-02-28 01:45:51 +07:00
import ExportedImage from "next-image-export-optimizer";
2024-01-31 00:49:51 +07:00
const Feed = ({
media,
type,
setOverlayContent,
currentIndex,
limitPerPage,
}) => (
<main className="grid grid-cols-3 gap-1">
{media
.slice(currentIndex, limitPerPage)
.map(({ id, url, previewPath, embedPath = url }) => (
<a
key={id}
href={url}
target="_blank"
rel="noopener noreferer"
2024-02-02 18:44:54 +07:00
className="hover:opacity-70"
2024-01-31 00:49:51 +07:00
onClick={(e) => {
e.preventDefault();
setOverlayContent({
url: embedPath,
type,
});
}}
>
2024-02-28 01:45:51 +07:00
<ExportedImage
alt={url}
loading="lazy"
src={previewPath}
width="512"
height="512"
className={`aspect-${type} bg-neutral-100 dark:bg-neutral-900`}
/>
2024-01-31 00:49:51 +07:00
</a>
))}
</main>
);
export default Feed;