1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-04-27 11:38:28 -04:00

25 lines
768 B
TypeScript

import Image from "../Image/Image";
import innerText from "react-innertext";
import classNames from "classnames";
import type { ReactNode } from "react";
import type { ImageProps as NextImageProps } from "next/image";
import styles from "./Figure.module.css";
type Props = Omit<NextImageProps, "alt"> & {
children: ReactNode;
alt?: string; // becomes optional -- pulled from plaintext-ified caption if missing
className?: string;
};
const Figure = ({ children, alt, className, ...imageProps }: Props) => {
return (
<figure className={classNames(styles.figure, className)}>
<Image alt={alt || innerText(children)} {...imageProps} />
<figcaption className={styles.caption}>{children}</figcaption>
</figure>
);
};
export default Figure;