import React from 'react';
import NextImage, { ImageProps } from 'next/image';
import { useBasePath } from '@digigov/nextjs/hooks';

const Image: React.FC<ImageProps> = ({ src, ...rest }) => {
  const basePathSrc = useBasePath(typeof src === 'string' ? src : '');
  return (
    <NextImage src={typeof src === 'string' ? basePathSrc : src} {...rest} />
  );
};

export default Image;
