@@ -6,6 +6,7 @@ import {Children, useContext, useMemo} from 'react';
66import * as React from 'react' ;
77import cn from 'classnames' ;
88import type { HTMLAttributes } from 'react' ;
9+ import Image from 'next/image' ;
910
1011import CodeBlock from './CodeBlock' ;
1112import { CodeDiagram } from './CodeDiagram' ;
@@ -285,9 +286,11 @@ function Illustration({
285286 return (
286287 < div className = "relative group before:absolute before:-inset-y-16 before:inset-x-0 my-16 mx-0 2xl:mx-auto max-w-4xl 2xl:max-w-6xl" >
287288 < figure className = "my-8 flex justify-center" >
288- < img
289+ < Image
289290 src = { src }
290291 alt = { alt }
292+ width = { 700 }
293+ height = { 300 }
291294 style = { { maxHeight : 300 } }
292295 className = "rounded-lg"
293296 />
@@ -321,11 +324,12 @@ function IllustrationBlock({
321324 const images = imageInfos . map ( ( info , index ) => (
322325 < figure key = { index } >
323326 < div className = "bg-white rounded-lg p-4 flex-1 flex xl:p-6 justify-center items-center my-4" >
324- < img
327+ < Image
325328 className = "text-primary"
326329 src = { info . src }
327330 alt = { info . alt }
328- height = { info . height }
331+ width = { 700 }
332+ height = { info . height || 300 }
329333 />
330334 </ div >
331335 { info . caption ? (
@@ -455,9 +459,17 @@ function YouTubeIframe(props: any) {
455459 ) ;
456460}
457461
458- function Image ( props : any ) {
462+ function CustomImage ( props : any ) {
459463 const { alt, ...rest } = props ;
460- return < img alt = { alt } className = "max-w-[calc(min(700px,100%))]" { ...rest } /> ;
464+ return (
465+ < Image
466+ alt = { alt }
467+ className = "max-w-[calc(min(700px,100%))]"
468+ width = { 700 }
469+ height = { 400 }
470+ { ...rest }
471+ />
472+ ) ;
461473}
462474
463475export const MDXComponents = {
@@ -474,7 +486,7 @@ export const MDXComponents = {
474486 h5 : H5 ,
475487 hr : Divider ,
476488 a : Link ,
477- img : Image ,
489+ img : CustomImage ,
478490 BlogCard,
479491 code : InlineCode ,
480492 pre : CodeBlock ,
0 commit comments