Skip to content

Commit 686d8d8

Browse files
Refactor IPFS image handling in listing metadata generation and update button title for mini app integration. Simplify listing details rendering by removing unnecessary capitalization in the page component.
1 parent e8894ec commit 686d8d8

File tree

2 files changed

+11
-29
lines changed

2 files changed

+11
-29
lines changed

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

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { resolveIpfsUrl } from "../../../services/ipfs/fetch";
12
import type { Metadata } from "next";
23

34
export const dynamic = "force-dynamic";
@@ -43,57 +44,38 @@ export async function generateMetadata(props: any): Promise<Metadata> {
4344
const listing = json?.data?.listings ?? null;
4445
if (listing) {
4546
title = listing.title || title;
46-
// Resolve IPFS-ish images to gateway URL if needed
47-
try {
48-
const val: string | undefined = (() => {
49-
const raw = String(listing.image || "").trim();
50-
if (!raw) return undefined;
51-
if (raw.startsWith("http://") || raw.startsWith("https://")) return raw;
52-
const path = raw.startsWith("ipfs://") ? raw.slice("ipfs://".length) : raw;
53-
const gw = process.env.NEXT_PUBLIC_PINATA_GATEWAY || "https://ipfs.io/ipfs/";
54-
const base = gw.endsWith("/") ? gw : `${gw}/`;
55-
return `${base}${path}`;
56-
})();
57-
imageUrl = val;
58-
} catch {}
47+
const resolved = resolveIpfsUrl(listing.image) || listing.image;
48+
if (resolved && typeof resolved === "string") imageUrl = resolved;
5949
}
6050
}
6151
} catch {}
6252

6353
const fallbackImage = `${baseUrl}/thumbnail.jpg`;
6454

65-
const titleTruncated = (process.env.NEXT_PUBLIC_APP_NAME || "View Listing").slice(0, 32);
6655
const embedMiniapp = {
6756
version: "1",
6857
imageUrl: imageUrl || process.env.NEXT_PUBLIC_IMAGE_URL || fallbackImage,
6958
button: {
70-
title: titleTruncated,
59+
title: "View Listing",
7160
action: {
61+
name: title,
7262
type: "launch_miniapp",
7363
url: `${baseUrl}/listing/${id}`,
74-
},
75-
},
76-
};
77-
const embedFrame = {
78-
...embedMiniapp,
79-
button: {
80-
...embedMiniapp.button,
81-
action: {
82-
...embedMiniapp.button.action,
83-
type: "launch_frame",
64+
splashImageUrl: `${baseUrl}/EBicon.png`,
65+
splashBackgroundColor: "#f8f5f0",
8466
},
8567
},
8668
};
8769

8870
return {
89-
title: `${title} | Ethereum Bazaar`,
71+
title: `${title} | View Listing`,
9072
openGraph: {
91-
title: `${title} | Ethereum Bazaar`,
73+
title: `${title} | View Listing`,
9274
images: [imageUrl || fallbackImage],
9375
},
9476
other: {
9577
"fc:miniapp": JSON.stringify(embedMiniapp),
96-
"fc:frame": JSON.stringify(embedFrame),
78+
"fc:frame": JSON.stringify(embedMiniapp),
9779
},
9880
};
9981
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ const ListingDetailsPageInner = () => {
334334
.filter(([, v]) => typeof v === "string" && v.trim().length > 0)
335335
.map(([k, v]) => (
336336
<li key={k} className="flex items-center">
337-
<span className="capitalize">
337+
<span>
338338
{k}: {v}
339339
</span>
340340
</li>

0 commit comments

Comments
 (0)