import * as React from "react"; import { connect, useConnect } from "frontity"; import { Frontity } from "frontity/types"; /** * Props for the {@link Image} component. */ export interface ImageProps extends React.ImgHTMLAttributes { /** * CSS class(es). */ className?: string; /** * The `rootMargin` of useInView. * * @deprecated This property was used in the previous version of the Image * component and has no effect anymore as the Image component relies only on * native lazy-loading. */ rootMargin?: number; } /** * The Image component. * * @param props - Defined in {@link ImageProps}. * @returns A React component. */ const Image: React.FC = ({ loading = "lazy", className, width, height, alt, ...props }) => { const { state } = useConnect(); if (state.frontity.mode === "amp") { let layout = "fill"; if (height && width) { layout = "responsive"; } return ( ); } return ( {alt} ); }; export default connect(Image, { injectProps: false });