From 47e3f1ff24c4b338b16dc2ef1b3ce864d7817d7b Mon Sep 17 00:00:00 2001 From: Rishi Date: Mon, 12 May 2025 15:47:12 +0200 Subject: [PATCH] update: use fallback og image for local --- frontend/src/app/share/[threadId]/layout.tsx | 35 ++++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/frontend/src/app/share/[threadId]/layout.tsx b/frontend/src/app/share/[threadId]/layout.tsx index be460164..c27b77dc 100644 --- a/frontend/src/app/share/[threadId]/layout.tsx +++ b/frontend/src/app/share/[threadId]/layout.tsx @@ -13,6 +13,7 @@ export async function generateMetadata({ params }): Promise { }, }; + try { const threadData = await getThread(threadId); const projectData = await getProject(threadData.project_id); @@ -21,19 +22,31 @@ export async function generateMetadata({ params }): Promise { return fallbackMetaData; } + const isDevelopment = + process.env.NODE_ENV === 'development' || + process.env.NEXT_PUBLIC_ENV_MODE === 'LOCAL' || + process.env.NEXT_PUBLIC_ENV_MODE === 'local'; + + const title = projectData.name || 'Shared Conversation | Kortix Suna'; + const description = projectData.description || 'Replay this Agent conversation on Kortix Suna'; + const ogImage = isDevelopment + ? `${process.env.NEXT_PUBLIC_URL}/share-page/og-fallback.png` + : `${process.env.NEXT_PUBLIC_URL}/api/share-page/og-image?title=${projectData.name}`; + return { - title: projectData.name || 'Shared Conversation | Kortix Suna', - description: - projectData.description || - 'Replay this Agent conversation on Kortix Suna', + title, + description, openGraph: { - title: projectData.name || 'Shared Conversation | Kortix Suna', - description: - projectData.description || - 'Replay this Agent conversation on Kortix Suna', - images: [ - `${process.env.NEXT_PUBLIC_URL}/api/share-page/og-image?title=${projectData.name}`, - ], + title, + description, + images: [ogImage], + }, + twitter: { + title, + description, + images: ogImage, + creator: '@kortixai', + card: 'summary_large_image', }, }; } catch (error) {