mirror of
https://github.com/DefectingCat/DefectingCat.github.io
synced 2025-07-15 16:51:37 +00:00
22 lines
559 B
TypeScript
22 lines
559 B
TypeScript
import NextImage, { ImageProps } from 'next/image';
|
|
|
|
interface Props extends ImageProps {}
|
|
|
|
const Image = ({ alt, ...rest }: Props) => {
|
|
const supportImg = ['jpeg', 'png', 'webp', 'avif'];
|
|
const placeholder = supportImg.includes((rest.src as { src: string }).src)
|
|
? 'blur'
|
|
: 'empty';
|
|
|
|
return (
|
|
<>
|
|
<span className="block text-center">
|
|
<NextImage alt={alt} placeholder={placeholder} {...rest} />
|
|
{alt && <span className="block text-center text-gray-400">{alt}</span>}
|
|
</span>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default Image;
|