Add SweetHome logo as OG image fallback for Facebook share
All checks were successful
Build frontend / build (push) Successful in 38s
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:
@ -61,9 +61,15 @@ export async function generateMetadata({ params }) {
|
|||||||
|
|
||||||
const p = mapProperty(raw);
|
const p = mapProperty(raw);
|
||||||
const priceStr = `${p.price.toLocaleString()} ل.س / ${p.priceUnit === 'daily' ? 'يوم' : 'شهر'}`;
|
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}`)
|
? (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 {
|
return {
|
||||||
title: `${p.title} - ${priceStr}`,
|
title: `${p.title} - ${priceStr}`,
|
||||||
@ -71,8 +77,8 @@ export async function generateMetadata({ params }) {
|
|||||||
openGraph: {
|
openGraph: {
|
||||||
title: `${p.title} - ${priceStr}`,
|
title: `${p.title} - ${priceStr}`,
|
||||||
description: p.description,
|
description: p.description,
|
||||||
images: imageUrl ? [imageUrl] : [],
|
images: ogImages,
|
||||||
url: `https://sweethome.example/property/${id}`,
|
url: `http://45.93.137.91/property/${id}`,
|
||||||
type: 'website',
|
type: 'website',
|
||||||
siteName: 'SweetHome',
|
siteName: 'SweetHome',
|
||||||
},
|
},
|
||||||
@ -80,7 +86,7 @@ export async function generateMetadata({ params }) {
|
|||||||
card: 'summary_large_image',
|
card: 'summary_large_image',
|
||||||
title: `${p.title} - ${priceStr}`,
|
title: `${p.title} - ${priceStr}`,
|
||||||
description: p.description,
|
description: p.description,
|
||||||
images: imageUrl ? [imageUrl] : [],
|
images: ogImages.map(i => i.url),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user