Skip to content

Commit

Permalink
WIP: optimize photos
Browse files Browse the repository at this point in the history
  • Loading branch information
gokh4nozturk committed Oct 25, 2023
1 parent 8bf4218 commit 235a37c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app/photos/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@ export default async function Photos() {

return (
<div className="grid gap-4 sm:grid-cols-2">
{images.map(photo => (
<Photo key={photo.id} data={photo} />
{images.map((photo, index) => (
<Photo key={photo.id} data={photo} index={index} />
))}
</div>
)
}

function Photo({ data: photo }) {
function Photo({ data: photo, index }) {
const { urls, description, alt_description, width, height, links } = photo
return (
<NextLink href={links.html}>
<NextImage
priority={index < 2}
loading={index < 2 ? 'eager' : 'lazy'}
className="rounded-lg"
loading="lazy"
src={urls.raw}
width={width}
height={height}
Expand Down

0 comments on commit 235a37c

Please sign in to comment.