From f25546e830052989740911d16e3a7e7f454a86f0 Mon Sep 17 00:00:00 2001 From: mvvasilev Date: Thu, 11 Jan 2024 21:55:13 +0200 Subject: [PATCH] Dynamic link preview --- frontend/src/pages/ExistingEventPage.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/frontend/src/pages/ExistingEventPage.tsx b/frontend/src/pages/ExistingEventPage.tsx index e19a47e..f20118d 100644 --- a/frontend/src/pages/ExistingEventPage.tsx +++ b/frontend/src/pages/ExistingEventPage.tsx @@ -91,6 +91,24 @@ export default function ExistingEventPage() { useEffect(() => { document.title = `findtheti.me - ${event.name}`; + + const ogTitleMeta = document.querySelector('meta[property="og:title"]'); + const ogUrlMeta = document.querySelector('meta[property="og:url"]'); + const ogDescriptionMeta = document.querySelector('meta[property="og:description"]'); + + // Update the content of the Open Graph meta tags + if (ogTitleMeta) { + ogTitleMeta.setAttribute('content', `findtheti.me - ${event.name}`); + } + + if (ogDescriptionMeta) { + ogDescriptionMeta.setAttribute('content', `${event.description || 'A simple to use scheduling assistant'}`); + } + + if (ogUrlMeta) { + ogUrlMeta.setAttribute('content', `${window.location.origin}/${eventId}`) + } + }, [event]) useEffect(() => {