import ImageBase from 'next/future/image';
import { FC } from 'react';
import config from './config';

type Props = Record<'src' | 'alt', string>;

const localizeSrc = (src: string) => {
  if (src.startsWith('http')) return src;
  return config.CDN + src;
}

const Image: FC<Props> = ({ src, ...props }) => {
  const source = localizeSrc(src);

  return (
    <ImageBase src={source} {...props} />
  )
}

export default Image;
