ig.rizaldy.club/components/Feed.js

34 lines
766 B
JavaScript
Raw Normal View History

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-02 11:49:25 +07:00
<img alt={url} loading="lazy" src={previewPath} className={`aspect-${type} bg-neutral-100 dark:bg-neutral-900`} />
2024-01-31 00:49:51 +07:00
</a>
))}
</main>
);
export default Feed;