11"use client" ;
22
33import Image from "next/image" ;
4+ import netlifyImageLoader , {
5+ getNetlifyImageSrcSet ,
6+ getNetlifyImageUrl ,
7+ } from "@/lib/netlify-image-loader" ;
48
59interface MdxImageProps {
610 src ?: string ;
@@ -14,7 +18,8 @@ export function MdxImage({ src, alt, className }: MdxImageProps) {
1418 }
1519
1620 const isLocal = src . startsWith ( "/" ) ;
17- const cdnSrc = isLocal ? `/.netlify/images?url=${ encodeURIComponent ( src ) } ` : src ;
21+ const cdnSrc = isLocal ? getNetlifyImageUrl ( src , 800 ) : src ;
22+ const cdnSrcSet = isLocal ? getNetlifyImageSrcSet ( src ) : undefined ;
1823 const isVideo = src . endsWith ( ".mp4" ) || src . endsWith ( ".webm" ) || src . endsWith ( ".mov" ) ;
1924 const isGif = src . endsWith ( ".gif" ) ;
2025
@@ -43,12 +48,15 @@ export function MdxImage({ src, alt, className }: MdxImageProps) {
4348 return (
4449 < span className = "group relative my-6 block w-full overflow-hidden rounded-md bg-gray-100 shadow-sm dark:bg-gray-800" >
4550 { /* biome-ignore lint/performance/noImgElement: Next.js Image Optimization warnings */ }
46- { /** biome-ignore lint/correctness/useImageSize: Decorative preview */ }
4751 < img
4852 alt = { alt || "" }
4953 className = { `h-auto w-full object-cover ${ className || "" } ` }
54+ height = { 450 }
5055 loading = "lazy"
56+ sizes = "(max-width: 768px) 100vw, (max-width: 1200px) 80vw, 900px"
5157 src = { cdnSrc }
58+ srcSet = { cdnSrcSet }
59+ width = { 800 }
5260 />
5361 </ span >
5462 ) ;
@@ -60,6 +68,8 @@ export function MdxImage({ src, alt, className }: MdxImageProps) {
6068 alt = { alt || "" }
6169 className = { `h-auto w-full rounded-md shadow-sm ${ className || "" } ` }
6270 height = { 500 }
71+ loader = { isLocal ? netlifyImageLoader : undefined }
72+ loading = "lazy"
6373 sizes = "(max-width: 768px) 100vw, (max-width: 1200px) 80vw, 900px"
6474 src = { src }
6575 width = { 900 }
0 commit comments