fix: resolve header.json conflict

This commit is contained in:
2026-02-05 00:14:42 +07:00
20 changed files with 1034 additions and 207 deletions

View File

@@ -0,0 +1,40 @@
"use client";
import { useState } from "react";
import { imageUrl } from "../utils/image";
interface ImageWithFallbackProps {
src: string;
alt: string;
fallbackSrc?: string;
className?: string;
style?: React.CSSProperties;
}
export default function ImageWithFallback({
src,
alt,
fallbackSrc = "_images/default.jpg",
className,
style,
}: ImageWithFallbackProps) {
const [imgSrc, setImgSrc] = useState(imageUrl(src));
const [hasError, setHasError] = useState(false);
const handleError = () => {
if (!hasError) {
setHasError(true);
setImgSrc(imageUrl(fallbackSrc));
}
};
return (
<img
src={imgSrc}
alt={alt}
className={className}
style={style}
onError={handleError}
/>
);
}