add reusable ImageFigure component

This commit is contained in:
2024-07-07 17:43:19 +02:00
parent e03e2624db
commit ada7d25083
15 changed files with 70 additions and 58 deletions
+20 -2
View File
@@ -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} />;
}