fix: fix middlewares config

This commit is contained in:
2025-06-18 03:09:10 +08:00
parent 6726cafff4
commit cc06142050
4 changed files with 43 additions and 24 deletions

View File

@@ -1,9 +1,24 @@
import type { ComponentProps } from "react";
import { type ComponentProps } from "react";
export type ImgProps = Omit<ComponentProps<"img">, "alt"> &
Required<Pick<ComponentProps<"img">, "alt">>;
Required<Pick<ComponentProps<"img">, "alt">> & {
optimize?: boolean;
};
// biome-ignore lint/correctness/noUnusedVariables: <explanation>
const LEGACY_IMAGE_REGEX = /\.(jpg|jpeg|png|gif|svg)$/;
export const Img = (props: ImgProps) => {
// biome-ignore lint/nursery/noImgElement: <explanation>
return <img {...props} alt={props.alt} />;
const src = props.src;
if (!src) {
// biome-ignore lint/nursery/noImgElement: <explanation>
return <img {...props} alt={props.alt} />;
}
return (
<picture {...props}>
<img {...props} alt={props.alt} />
</picture>
);
};