Skip to content

Commit 09b1912

Browse files
committed
Shorten publisher address in OG image on published contract page (#5242)
## Problem solved Short description of the bug fixed or feature added <!-- start pr-codex --> --- ## PR-Codex overview This PR enhances the `publishedContractOGImageTemplate` function to conditionally shorten the display of the `publisher` address if it is a valid blockchain address. ### Detailed summary - Added import for `isAddress` and `shortenAddress` from `thirdweb`. - Updated the rendering of the `publisher` in the `<h2>` element to check if it is a valid address using `isAddress`. - If valid, it displays the shortened address using `shortenAddress`; otherwise, it displays the full `publisher` name. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 975cd0b commit 09b1912

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

apps/dashboard/src/app/(dashboard)/published-contract/[publisher]/[contract_id]/utils/publishedContractOGImageTemplate.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/* eslint-disable @next/next/no-img-element */
22
import { getThirdwebClient } from "@/constants/thirdweb.server";
33
import { ImageResponse } from "next/og";
4+
import { isAddress } from "thirdweb";
45
import { download } from "thirdweb/storage";
6+
import { shortenAddress } from "thirdweb/utils";
57

68
const OgBrandIcon: React.FC = () => (
79
// biome-ignore lint/a11y/noSvgWithoutTitle: not needed
@@ -255,7 +257,9 @@ export async function publishedContractOGImageTemplate(params: {
255257
)}
256258

257259
<h2 tw="text-2xl text-white font-medium max-w-full">
258-
{params.publisher}
260+
{isAddress(params.publisher)
261+
? shortenAddress(params.publisher)
262+
: params.publisher}
259263
</h2>
260264
</div>
261265
</div>

0 commit comments

Comments
 (0)