aboutsummaryrefslogtreecommitdiff
path: root/src/Image.tsx
blob: 0989451f043e271497b7a3bc3b2142e09ade9177 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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;