Skip to content

Commit 7abd369

Browse files
feat(web): support custom display label for sponsor website links (#1094)
Add optional websiteLabel to the Sponsor type and a getSponsorUrlLabel helper so a sponsor's website link can show custom text while still linking to websiteUrl (e.g. show "CodeRabbit.ai" but link to a redirect URL). Falls back to the formatted URL when no label is set.
1 parent a5201d9 commit 7abd369

5 files changed

Lines changed: 20 additions & 8 deletions

File tree

apps/web/src/app/(home)/_components/sponsors-section.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { useState } from "react";
55
import { FaGithub } from "react-icons/fa6";
66

77
import {
8-
formatSponsorUrl,
98
getSponsorUrl,
9+
getSponsorUrlLabel,
1010
isLifetimeSpecialSponsor,
1111
shouldShowLifetimeTotal,
1212
} from "@/lib/sponsor-utils";
@@ -130,7 +130,7 @@ export default function SponsorsSection({ sponsorsData }: { sponsorsData: Sponso
130130
className="group flex items-center gap-2 text-muted-foreground text-xs transition-colors hover:text-primary"
131131
>
132132
<Globe className="size-3" />
133-
<span className="truncate">{formatSponsorUrl(sponsorUrl)}</span>
133+
<span className="truncate">{getSponsorUrlLabel(entry)}</span>
134134
</a>
135135
)}
136136
</div>
@@ -211,7 +211,7 @@ export default function SponsorsSection({ sponsorsData }: { sponsorsData: Sponso
211211
className="group flex items-center gap-2 text-muted-foreground text-xs transition-colors hover:text-primary"
212212
>
213213
<Globe className="size-3" />
214-
<span className="truncate">{formatSponsorUrl(sponsorUrl)}</span>
214+
<span className="truncate">{getSponsorUrlLabel(entry)}</span>
215215
</a>
216216
)}
217217
</div>
@@ -325,7 +325,7 @@ export default function SponsorsSection({ sponsorsData }: { sponsorsData: Sponso
325325
className="group flex items-center gap-2 text-muted-foreground/70 text-xs transition-colors hover:text-muted-foreground"
326326
>
327327
<Globe className="size-3" />
328-
<span className="truncate">{formatSponsorUrl(sponsorUrl)}</span>
328+
<span className="truncate">{getSponsorUrlLabel(entry)}</span>
329329
</a>
330330
)}
331331
</div>

apps/web/src/app/(home)/new/_components/special-sponsors-panel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Image from "next/image";
55
import { FaGithub } from "react-icons/fa6";
66

77
import { HoverCard, HoverCardContent, HoverCardTrigger } from "@/components/ui/hover-card";
8-
import { formatSponsorUrl, getSponsorUrl, shouldShowLifetimeTotal } from "@/lib/sponsor-utils";
8+
import { getSponsorUrl, getSponsorUrlLabel, shouldShowLifetimeTotal } from "@/lib/sponsor-utils";
99
import type { Sponsor } from "@/lib/types";
1010
import { cn } from "@/lib/utils";
1111

@@ -109,7 +109,7 @@ export function SpecialSponsorsPanel({ sponsors, compact = false }: SpecialSpons
109109
className="group flex items-center gap-2 text-muted-foreground text-xs transition-colors hover:text-primary"
110110
>
111111
<Globe className="h-3.5 w-3.5" />
112-
<span className="truncate">{formatSponsorUrl(sponsorUrl)}</span>
112+
<span className="truncate">{getSponsorUrlLabel(entry)}</span>
113113
</a>
114114
) : null}
115115
</div>

apps/web/src/components/special-sponsor-banner.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Image from "next/image";
33
import { FaGithub } from "react-icons/fa6";
44

55
import { HoverCard, HoverCardContent, HoverCardTrigger } from "@/components/ui/hover-card";
6-
import { formatSponsorUrl, getSponsorUrl, shouldShowLifetimeTotal } from "@/lib/sponsor-utils";
6+
import { getSponsorUrl, getSponsorUrlLabel, shouldShowLifetimeTotal } from "@/lib/sponsor-utils";
77
import { fetchSponsors } from "@/lib/sponsors";
88

99
export async function SpecialSponsorBanner() {
@@ -95,7 +95,7 @@ export async function SpecialSponsorBanner() {
9595
className="group flex items-center gap-2 text-muted-foreground text-xs transition-colors hover:text-primary"
9696
>
9797
<Globe className="h-4 w-4" />
98-
<span className="truncate">{formatSponsorUrl(sponsorUrl)}</span>
98+
<span className="truncate">{getSponsorUrlLabel(entry)}</span>
9999
</a>
100100
) : null}
101101
</div>

apps/web/src/lib/sponsor-utils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,11 @@ export const getSponsorUrl = (sponsor: Sponsor): string => {
3131
export const formatSponsorUrl = (url: string): string => {
3232
return url?.replace(/^https?:\/\//, "")?.replace(/\/$/, "");
3333
};
34+
35+
// Text shown for a sponsor's website link. Uses websiteLabel when provided
36+
// (so the display can differ from the actual link, e.g. a redirect URL),
37+
// otherwise falls back to the formatted website/GitHub URL.
38+
export const getSponsorUrlLabel = (sponsor: Sponsor): string => {
39+
const label = sponsor.websiteLabel?.trim();
40+
return label || formatSponsorUrl(getSponsorUrl(sponsor));
41+
};

apps/web/src/lib/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ export type Sponsor = {
3131
githubId: string;
3232
avatarUrl: string;
3333
websiteUrl?: string | null;
34+
// Optional display text for the website link. When set, show this label
35+
// instead of the URL while still linking to websiteUrl (e.g. show
36+
// "CodeRabbit.ai" but link to a redirect URL).
37+
websiteLabel?: string | null;
3438
githubUrl: string;
3539
tierName: string;
3640
totalProcessedAmount: number;

0 commit comments

Comments
 (0)