Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable NextImage for some images #27

Merged
merged 1 commit into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
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
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