|
| 1 | +import { resolveIpfsUrl } from "../../../services/ipfs/fetch"; |
1 | 2 | import type { Metadata } from "next"; |
2 | 3 |
|
3 | 4 | export const dynamic = "force-dynamic"; |
@@ -43,57 +44,38 @@ export async function generateMetadata(props: any): Promise<Metadata> { |
43 | 44 | const listing = json?.data?.listings ?? null; |
44 | 45 | if (listing) { |
45 | 46 | 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; |
59 | 49 | } |
60 | 50 | } |
61 | 51 | } catch {} |
62 | 52 |
|
63 | 53 | const fallbackImage = `${baseUrl}/thumbnail.jpg`; |
64 | 54 |
|
65 | | - const titleTruncated = (process.env.NEXT_PUBLIC_APP_NAME || "View Listing").slice(0, 32); |
66 | 55 | const embedMiniapp = { |
67 | 56 | version: "1", |
68 | 57 | imageUrl: imageUrl || process.env.NEXT_PUBLIC_IMAGE_URL || fallbackImage, |
69 | 58 | button: { |
70 | | - title: titleTruncated, |
| 59 | + title: "View Listing", |
71 | 60 | action: { |
| 61 | + name: title, |
72 | 62 | type: "launch_miniapp", |
73 | 63 | 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", |
84 | 66 | }, |
85 | 67 | }, |
86 | 68 | }; |
87 | 69 |
|
88 | 70 | return { |
89 | | - title: `${title} | Ethereum Bazaar`, |
| 71 | + title: `${title} | View Listing`, |
90 | 72 | openGraph: { |
91 | | - title: `${title} | Ethereum Bazaar`, |
| 73 | + title: `${title} | View Listing`, |
92 | 74 | images: [imageUrl || fallbackImage], |
93 | 75 | }, |
94 | 76 | other: { |
95 | 77 | "fc:miniapp": JSON.stringify(embedMiniapp), |
96 | | - "fc:frame": JSON.stringify(embedFrame), |
| 78 | + "fc:frame": JSON.stringify(embedMiniapp), |
97 | 79 | }, |
98 | 80 | }; |
99 | 81 | } |
|
0 commit comments