import React, { FC } from "react"; import { graphql, StaticQuery } from "gatsby"; import { GatsbyImage, GatsbyImageProps, IGatsbyImageData } from "gatsby-plugin-image"; import { FileSystemNode } from "gatsby-source-filesystem"; interface Props extends Omit { path: string; } interface Data { images: { edges: Array<{ node: FileSystemNode & { childImageSharp: { gatsbyImageData: IGatsbyImageData; }; }; }>; }; } const Image: FC = ({ path, ...rest }: Props) => ( { const { images: { edges = [] } = {} } = data; const image = edges.find(({ node }) => node.absolutePath.includes(path)); if (!image) { return null; } const { node: { childImageSharp }, } = image; return ; }} /> ); export default Image;