diff --git a/apps/web/src/components/ShareModal.tsx b/apps/web/src/components/ShareModal.tsx index f84884a..d93883e 100644 --- a/apps/web/src/components/ShareModal.tsx +++ b/apps/web/src/components/ShareModal.tsx @@ -25,6 +25,10 @@ export function ShareModal({ }: ShareModalProps) { const [copied, setCopied] = useState(false); const [imagePreview, setImagePreview] = useState(null); + + // Open Graph data for global article sharing + const [ogData, setOgData] = useState<{ image?: string, title?: string, description?: string } | null>(null); + const [timestamp] = useState( new Date().toLocaleTimeString("de-DE", { hour: "2-digit", @@ -33,6 +37,19 @@ export function ShareModal({ }), ); + useEffect(() => { + // Only extract OG data if we are sharing the global page (no specific diagram or QR) + if (isOpen && !diagramImage && !qrCodeData && typeof document !== "undefined") { + const ogImage = document.querySelector('meta[property="og:image"]')?.getAttribute("content") || undefined; + const ogTitle = document.querySelector('meta[property="og:title"]')?.getAttribute("content") || title; + const ogDesc = document.querySelector('meta[property="og:description"]')?.getAttribute("content") || undefined; + + if (ogImage || ogTitle || ogDesc) { + setOgData({ image: ogImage, title: ogTitle, description: ogDesc }); + } + } + }, [isOpen, diagramImage, qrCodeData, title]); + useEffect(() => { if (diagramImage && isOpen) { const isDataUrl = diagramImage.startsWith("data:image/"); @@ -194,7 +211,7 @@ export function ShareModal({

) : ( - title && ( + title && !ogData ? (
+ ) : ogData && ( +
+ +
+ {ogData.image && ( +
+ {ogData.title +
+ )} +
+

+ {ogData.title || title} +

+ {ogData.description && ( +

+ {ogData.description} +

+ )} +
+ MINTEL.ME +
+
+
+
) )}