mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-04-27 11:38:28 -04:00
24 lines
775 B
TypeScript
24 lines
775 B
TypeScript
import Image from "../Image/Image";
|
|
import innerText from "react-innertext";
|
|
import classNames from "classnames";
|
|
import type { PropsWithChildren } from "react";
|
|
import type { ImageProps as NextImageProps } from "next/image";
|
|
|
|
import styles from "./Figure.module.css";
|
|
|
|
export type FigureProps = Omit<NextImageProps, "alt"> &
|
|
PropsWithChildren<{
|
|
alt?: string; // becomes optional -- pulled from plaintext-ified caption if missing
|
|
}>;
|
|
|
|
const Figure = ({ children, alt, className, ...imageProps }: FigureProps) => {
|
|
return (
|
|
<figure className={classNames(styles.figure, className)}>
|
|
<Image alt={alt || innerText(children)} {...imageProps} />
|
|
<figcaption className={styles.caption}>{children}</figcaption>
|
|
</figure>
|
|
);
|
|
};
|
|
|
|
export default Figure;
|