Add SweetHome logo as OG image fallback for Facebook share
All checks were successful
Build frontend / build (push) Successful in 38s

- Always includes logo.png as OG image
- Property images shown first if available, logo as second
- If no property images, shows logo only
This commit is contained in:
Claw AI
2026-03-30 14:07:52 +00:00
parent d56b4d2a11
commit 9bf67ffa38

View File

@ -61,9 +61,15 @@ export async function generateMetadata({ params }) {
const p = mapProperty(raw);
const priceStr = `${p.price.toLocaleString()} ل.س / ${p.priceUnit === 'daily' ? 'يوم' : 'شهر'}`;
const imageUrl = p.image
const propertyImage = p.image
? (p.image.startsWith('http') ? p.image : `http://45.93.137.91${p.image}`)
: '';
const logoUrl = `http://45.93.137.91/logo.png`;
// Use property image if available, otherwise logo
const ogImages = propertyImage
? [{ url: propertyImage, width: 1200, height: 630 }, { url: logoUrl, width: 512, height: 512 }]
: [{ url: logoUrl, width: 512, height: 512 }];
return {
title: `${p.title} - ${priceStr}`,
@ -71,8 +77,8 @@ export async function generateMetadata({ params }) {
openGraph: {
title: `${p.title} - ${priceStr}`,
description: p.description,
images: imageUrl ? [imageUrl] : [],
url: `https://sweethome.example/property/${id}`,
images: ogImages,
url: `http://45.93.137.91/property/${id}`,
type: 'website',
siteName: 'SweetHome',
},
@ -80,7 +86,7 @@ export async function generateMetadata({ params }) {
card: 'summary_large_image',
title: `${p.title} - ${priceStr}`,
description: p.description,
images: imageUrl ? [imageUrl] : [],
images: ogImages.map(i => i.url),
},
};
}