@@ -107,29 +107,36 @@ async function fetchDroposal(id: string): Promise<{
107107export default async function Image ( { params } : Props ) {
108108 const { id } = await params ;
109109
110+ let fetched : Awaited < ReturnType < typeof fetchDroposal > > ;
110111 try {
111- const { proposal, decoded } = await fetchDroposal ( id ) ;
112+ fetched = await fetchDroposal ( id ) ;
113+ } catch ( error ) {
114+ console . error ( "[droposals OG] error:" , error ) ;
115+ return renderFallback ( "Error generating image" ) ;
116+ }
112117
113- if ( ! proposal ) {
114- return renderFallback ( "Droposal Not Found" ) ;
115- }
118+ const { proposal, decoded } = fetched ;
116119
117- const title = decoded ?. name || proposal . title || `Droposal #${ proposal . proposalNumber } ` ;
118- const imageWidth = 520 ;
119- const imageHeight = 510 ;
120- const imageUrl = toOgImageUrl ( decoded ?. imageURI ?? null , {
121- width : imageWidth ,
122- height : imageHeight ,
123- fit : "cover" ,
124- } ) ;
125- const priceEth = decoded ?. saleConfig ?. publicSalePrice
126- ? formatEthDisplay ( formatEther ( decoded . saleConfig . publicSalePrice ) )
127- : "Free" ;
128- const editionSize = decoded ?. editionSize || "Unlimited" ;
129- const description = decoded ?. collectionDescription || proposal . description || "NFT Drop" ;
120+ if ( ! proposal ) {
121+ return renderFallback ( "Droposal Not Found" ) ;
122+ }
130123
131- return new ImageResponse (
132- (
124+ const title = decoded ?. name || proposal . title || `Droposal #${ proposal . proposalNumber } ` ;
125+ const imageWidth = 520 ;
126+ const imageHeight = 510 ;
127+ const imageUrl = toOgImageUrl ( decoded ?. imageURI ?? null , {
128+ width : imageWidth ,
129+ height : imageHeight ,
130+ fit : "cover" ,
131+ } ) ;
132+ const priceEth = decoded ?. saleConfig ?. publicSalePrice
133+ ? formatEthDisplay ( formatEther ( decoded . saleConfig . publicSalePrice ) )
134+ : "Free" ;
135+ const editionSize = decoded ?. editionSize || "Unlimited" ;
136+ const description = decoded ?. collectionDescription || proposal . description || "NFT Drop" ;
137+
138+ return new ImageResponse (
139+ (
133140 < div
134141 style = { {
135142 height : "100%" ,
@@ -276,13 +283,9 @@ export default async function Image({ params }: Props) {
276283 </ div >
277284 </ div >
278285 </ div >
279- ) ,
280- { ...size }
281- ) ;
282- } catch ( error ) {
283- console . error ( "[droposals OG] error:" , error ) ;
284- return renderFallback ( "Error generating image" ) ;
285- }
286+ ) ,
287+ { ...size }
288+ ) ;
286289}
287290
288291function renderFallback ( message : string ) {
0 commit comments