add reusable ImageFigure component
This commit is contained in:
@@ -1,7 +1,25 @@
|
||||
import NextImage, { ImageProps as NextImageProps } from "next/image";
|
||||
import styles from "./image.module.scss";
|
||||
|
||||
type ImageProps = NextImageProps;
|
||||
type ImageProps = NextImageProps & {
|
||||
attribution?: string | null;
|
||||
caption?: string | null;
|
||||
imageFormat?: string | null; // "original" | "bleed" | "fullWidth"
|
||||
};
|
||||
|
||||
export default function Image(props: ImageProps) {
|
||||
export function ImageFigure(props: ImageProps) {
|
||||
const { attribution, caption, imageFormat, ...nextImageProps } = props;
|
||||
return (
|
||||
<figure
|
||||
className={`${styles.image} ${imageFormat ? styles[imageFormat] : ""}`}
|
||||
>
|
||||
<NextImage {...nextImageProps} />
|
||||
{attribution && <div className={styles.attribution}>{attribution}</div>}
|
||||
{caption && <figcaption>{caption}</figcaption>}
|
||||
</figure>
|
||||
);
|
||||
}
|
||||
|
||||
export function Image(props: NextImageProps) {
|
||||
return <NextImage {...props} />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user