fix: provide ResponsiveImage component to MDXRemote in dynamic routes to prevent crashes
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 21s
Build & Deploy / 🧪 QA (push) Failing after 1m23s
Build & Deploy / 🏗️ Build (push) Has been skipped
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 3s

This commit is contained in:
2026-07-23 11:16:26 +02:00
parent 68be6ff8dd
commit 9e70379aba
3 changed files with 63 additions and 0 deletions

View File

@@ -1,4 +1,5 @@
import { Container, Heading, Badge } from '@/components/ui';
import { getImageProps } from 'next/image';
import { getTranslations, setRequestLocale } from 'next-intl/server';
import { Metadata } from 'next';
import { getAllReferences } from '@/lib/references';
@@ -40,6 +41,26 @@ const mdxComponents = {
li: CustomLi,
p: (props: any) => <p className="text-neutral-600 text-sm mb-4 leading-relaxed" {...props} />,
Heading,
ResponsiveImage: (props: any) => {
let src = props.src;
if (typeof src === 'string' && src.startsWith('/_next/image')) {
try {
const urlParam = new URLSearchParams(src.split('?')[1]).get('url');
if (urlParam) src = decodeURIComponent(urlParam);
} catch (e) {}
}
const { props: { srcSet, src: finalSrc, sizes } } = getImageProps({
src,
alt: props.alt || '',
width: 1920,
height: 1080,
sizes: '(max-width: 768px) 100vw, (max-width: 1200px) 75vw, 50vw',
quality: 80,
});
return (
<img {...props} src={finalSrc} srcSet={srcSet} sizes={sizes} loading="lazy" decoding="async" />
);
},
};
interface PageProps {