diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-02-22 15:06:09 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-02-22 15:37:29 +0100 |
| commit | d73f91150855a97b8dc830a83572cbaaf1d95356 (patch) | |
| tree | 2c351a337dfad104a53d2dc313ff7b88d3ae9bbb /src/components/MDX/ResponsiveImage/ResponsiveImage.tsx | |
| parent | 4c7ba0ac4b13fea4e6cb78481177ac7feca895ea (diff) | |
chore(homepage): use next/image for images and specify width/height
Diffstat (limited to 'src/components/MDX/ResponsiveImage/ResponsiveImage.tsx')
| -rw-r--r-- | src/components/MDX/ResponsiveImage/ResponsiveImage.tsx | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/components/MDX/ResponsiveImage/ResponsiveImage.tsx b/src/components/MDX/ResponsiveImage/ResponsiveImage.tsx index 062c04b..6c39e7f 100644 --- a/src/components/MDX/ResponsiveImage/ResponsiveImage.tsx +++ b/src/components/MDX/ResponsiveImage/ResponsiveImage.tsx @@ -1,12 +1,8 @@ -import Image, { ImageProps } from 'next/image'; +import { ResponsiveImageProps } from '@ts/types/app'; +import Image from 'next/image'; import Link from 'next/link'; import styles from './ResponsiveImage.module.scss'; -type ResponsiveImageProps = ImageProps & { - caption?: string; - linkTarget?: string; -}; - const ResponsiveImage = (props: ResponsiveImageProps) => { const { caption, linkTarget, ...attributes } = props; @@ -15,7 +11,11 @@ const ResponsiveImage = (props: ResponsiveImageProps) => { {linkTarget ? ( <Link href={linkTarget}> <a className={styles.link}> - <Image alt={attributes.alt} layout="intrinsic" {...attributes} /> + <Image + alt={attributes.alt} + layout={attributes.layout || 'intrinsic'} + {...attributes} + /> {caption && ( <figcaption className={styles.caption}>{caption}</figcaption> )} @@ -23,7 +23,11 @@ const ResponsiveImage = (props: ResponsiveImageProps) => { </Link> ) : ( <> - <Image alt={attributes.alt} layout="intrinsic" {...attributes} /> + <Image + alt={attributes.alt} + layout={attributes.layout || 'intrinsic'} + {...attributes} + /> {caption && ( <figcaption className={styles.caption}>{caption}</figcaption> )} |
