Skip to content

Commit

Permalink
Merge pull request #27 from abdielou/feature/cache-workaroud
Browse files Browse the repository at this point in the history
Disable NextImage for some images
  • Loading branch information
abdielou committed Aug 23, 2022
2 parents 622ad55 + 3d5e057 commit 488d34c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 45 deletions.
19 changes: 16 additions & 3 deletions components/Card.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import Image from './Image'
import Link from './Link'

const Card = ({ title, description, imgSrc, href, width = 1088, height = 612 }) => (
const OptimizedImage = ({ imageOptimize, ...rest }) =>
imageOptimize ? <Image {...rest} /> : <img {...rest} />

const Card = ({
title,
description,
imgSrc,
href,
width = 1088,
height = 612,
imageOptimize = true,
}) => (
<div className="p-4">
<div className="h-full overflow-hidden border-2 border-gray-200 rounded-md border-opacity-60 dark:border-gray-700">
<div className="p-6">
Expand All @@ -18,21 +29,23 @@ const Card = ({ title, description, imgSrc, href, width = 1088, height = 612 })
</div>
{href ? (
<Link href={href} aria-label={`Link to ${title}`}>
<Image
<OptimizedImage
alt={title}
src={imgSrc}
className="object-cover object-center"
width={width}
height={height}
imageOptimize={imageOptimize}
/>
</Link>
) : (
<Image
<OptimizedImage
alt={title}
src={imgSrc}
className="object-cover object-center"
width={width}
height={height}
imageOptimize={imageOptimize}
/>
)}
</div>
Expand Down
3 changes: 3 additions & 0 deletions data/weatherData.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const projectsData = [
href: 'https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/taw/GEOCOLOR/1800x1080.jpg',
width: '1800',
height: '1080',
imageOptimize: false,
},
{
title: 'Caribe',
Expand All @@ -20,6 +21,7 @@ const projectsData = [
href: 'https://cdn.star.nesdis.noaa.gov//GOES16/ABI/SECTOR/CAR/13/GOES16-CAR-13-1000x1000.gif',
width: '1000',
height: '1000',
imageOptimize: false,
},
{
title: 'Radar Doppler',
Expand Down Expand Up @@ -71,6 +73,7 @@ const projectsData = [
'https://cdn.star.nesdis.noaa.gov//GOES16/ABI/SECTOR/TAW/GEOCOLOR/GOES16-TAW-GEOCOLOR-900x540.gif',
width: '900',
height: '540',
imageOptimize: false,
},
{
title: 'Red Sísmica de Puerto Rico',
Expand Down
42 changes: 0 additions & 42 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pages/weather.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default function Projects() {
href={d.href}
width={adjustedSize.width}
height={adjustedSize.height}
imageOptimize={d.imageOptimize}
/>
)
})}
Expand Down

1 comment on commit 488d34c

@vercel
Copy link

@vercel vercel bot commented on 488d34c Aug 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.