Skip to content

Commit f3bacc1

Browse files
committed
[MNY-203] Dashboard: ERC20 token page title, metadata and OG updates (#8194)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR updates the logic for generating `title` and `description` variables in the `shared-layout.tsx` file, particularly for different types of smart contracts. It enhances the information displayed for ERC20 contracts and adds fallback values for when contract metadata is not available. ### Detailed summary - Changed `const title` to `let title` to allow reassignment. - Updated `title` and `description` for `ERC20` contracts using `contractMetadata`. - Added fallback values for `title` and `description` when an error occurs, including `openGraph` properties. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Richer link previews for contract pages via Open Graph metadata, improving social sharing and discoverability. * More accurate, branded titles and descriptions: ERC20 pages use token name and symbol; non-ERC20 pages use contract name, with references to Buy, Swap, Bridge & Price. * Robust fallbacks ensure meaningful titles, descriptions, and previews even if metadata loading fails. * Consistent metadata across success and fallback states for a more reliable sharing experience. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 968913d commit f3bacc1

File tree

1 file changed

+17
-5
lines changed
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]

1 file changed

+17
-5
lines changed

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/shared-layout.tsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,25 +190,37 @@ export async function generateContractLayoutMetadata(params: {
190190
.replace("Testnet", "")
191191
.trim();
192192

193-
const title = `${contractDisplayName} | ${cleanedChainName} Smart Contract`;
193+
let title = `${contractDisplayName} | ${cleanedChainName} Smart Contract`;
194194
let description = "";
195195

196196
if (isERC721 || isERC1155) {
197197
description = `View tokens, source code, transactions, balances, and analytics for the ${contractDisplayName} smart contract on ${cleanedChainName}.`;
198198
} else if (isERC20) {
199-
description = `View ERC20 tokens, transactions, balances, source code, and analytics for the ${contractDisplayName} smart contract on ${cleanedChainName}`;
199+
title = `${contractMetadata.name} (${contractMetadata.symbol}) on ${cleanedChainName} | Buy, Swap, Bridge & Price`;
200+
description = `Buy, swap & bridge ${contractMetadata.name} (${contractMetadata.symbol}) on ${cleanedChainName} with thirdweb Bridge. View contract address, holders, analytics, transactions and live price.`;
200201
} else {
201-
description = `View tokens, transactions, balances, source code, and analytics for the ${contractDisplayName} smart contract on ${cleanedChainName}`;
202+
description = `View tokens, transactions, balances, source code, and analytics for the ${contractMetadata.name} smart contract on ${cleanedChainName}`;
202203
}
203204

204205
return {
205206
description: description,
206207
title: title,
208+
openGraph: {
209+
description: description,
210+
title: title,
211+
},
207212
};
208213
} catch {
214+
const fallbackTitle = `${shortenIfAddress(params.contractAddress)} | ${params.chainIdOrSlug}`;
215+
const fallbackDescription = `View tokens, transactions, balances, source code, and analytics for the smart contract on Chain ID ${params.chainIdOrSlug}`;
216+
209217
return {
210-
description: `View tokens, transactions, balances, source code, and analytics for the smart contract on Chain ID ${params.chainIdOrSlug}`,
211-
title: `${shortenIfAddress(params.contractAddress)} | ${params.chainIdOrSlug}`,
218+
description: fallbackDescription,
219+
title: fallbackTitle,
220+
openGraph: {
221+
description: fallbackDescription,
222+
title: fallbackTitle,
223+
},
212224
};
213225
}
214226
}

0 commit comments

Comments
 (0)