feat: deal with broken images
This commit is contained in:
parent
6ffe46e39b
commit
a4ccdfce22
|
|
@ -39,6 +39,10 @@ export function Markdown({
|
||||||
}
|
}
|
||||||
return [rehypeKatex];
|
return [rehypeKatex];
|
||||||
}, [animate]);
|
}, [animate]);
|
||||||
|
const handleImgError = (e: React.SyntheticEvent<HTMLImageElement>) => {
|
||||||
|
e.currentTarget.style.display = "none";
|
||||||
|
console.warn(`Markdown: Image "${e.currentTarget.src}" failed to load`);
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cn(className, "markdown flex flex-col gap-4")}
|
className={cn(className, "markdown flex flex-col gap-4")}
|
||||||
|
|
@ -53,6 +57,9 @@ export function Markdown({
|
||||||
{children}
|
{children}
|
||||||
</a>
|
</a>
|
||||||
),
|
),
|
||||||
|
img: ({ src, alt }) => (
|
||||||
|
<img src={src} alt={alt} onError={handleImgError} />
|
||||||
|
),
|
||||||
}}
|
}}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue