Skip to content

Commit b589e4f

Browse files
Merge pull request #12 from websurferdoteth/fix/og-image-unfurl
2 parents cf962c0 + 881121d commit b589e4f

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

packages/nextjs/app/listing/[id]/layout.tsx

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export async function generateMetadata(props: any): Promise<Metadata> {
1818
const ponderUrl = process.env.NEXT_PUBLIC_PONDER_URL || "http://localhost:42069/graphql";
1919

2020
let title = `Listing ${id}`;
21+
let description: string | undefined;
2122
let imageUrl: string | undefined;
2223

2324
try {
@@ -44,34 +45,56 @@ export async function generateMetadata(props: any): Promise<Metadata> {
4445
const listing = json?.data?.listings ?? null;
4546
if (listing) {
4647
title = listing.title || title;
48+
description = listing.description || undefined;
4749
const resolved = resolveIpfsUrl(listing.image) || listing.image;
4850
if (resolved && typeof resolved === "string") imageUrl = resolved;
4951
}
5052
}
5153
} catch {}
5254

5355
const fallbackImage = `${baseUrl}/thumbnail.jpg`;
56+
const listingUrl = `${baseUrl}/listing/${id}`;
57+
const displayTitle = `${title} | Ethereum Bazaar`;
58+
const displayDescription = description || `View this listing on Ethereum Bazaar`;
59+
imageUrl = imageUrl || process.env.NEXT_PUBLIC_IMAGE_URL || fallbackImage;
5460

5561
const embedMiniapp = {
5662
version: "1",
57-
imageUrl: imageUrl || process.env.NEXT_PUBLIC_IMAGE_URL || fallbackImage,
63+
imageUrl: imageUrl,
5864
button: {
5965
title: "View Listing",
6066
action: {
6167
name: title,
6268
type: "launch_miniapp",
63-
url: `${baseUrl}/listing/${id}`,
69+
url: listingUrl,
6470
splashImageUrl: `${baseUrl}/EBicon.png`,
6571
splashBackgroundColor: "#f8f5f0",
6672
},
6773
},
6874
};
6975

7076
return {
71-
title: `${title} | View Listing`,
77+
metadataBase: new URL(baseUrl),
78+
title: displayTitle,
79+
description: displayDescription,
7280
openGraph: {
73-
title: `${title} | View Listing`,
74-
images: [imageUrl || fallbackImage],
81+
type: "website",
82+
url: listingUrl,
83+
title: displayTitle,
84+
description: displayDescription,
85+
siteName: "Ethereum Bazaar",
86+
images: [
87+
{
88+
url: imageUrl,
89+
alt: title,
90+
},
91+
],
92+
},
93+
twitter: {
94+
card: "summary_large_image",
95+
title: displayTitle,
96+
description: displayDescription,
97+
images: [imageUrl],
7598
},
7699
other: {
77100
"fc:miniapp": JSON.stringify(embedMiniapp),

0 commit comments

Comments
 (0)