Skip to content

Commit 90d44be

Browse files
committed
fix(profile): use NEXT_PUBLIC_SITE_URL for badge links, remove unused badge state
1 parent 3bd5737 commit 90d44be

2 files changed

Lines changed: 11 additions & 16 deletions

File tree

‎.env.example‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ GITHUB_PR_COUNT=80
1616
GITHUB_ISSUE_COUNT=20
1717
GITHUB_DISCUSSION_COUNT=10
1818
GITHUB_USER_STALE_DAYS=14
19+
NEXT_PUBLIC_SITE_URL=https://your-domain.com
1920

2021
# ── Database (PostgreSQL) ───────────────────────────────────────────────────
2122
DATABASE_URL=postgresql://devimpact:devimpact@localhost:5432/devimpact?sslmode=disable

‎src/features/developer/components/user-profile-client.tsx‎

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ export function UserProfileClient({ user, location, countryParam }: Props) {
5252
const { copied, copy } = useClipboardCopy();
5353
const { copied: markdownCopied, copy: copyMarkdown } = useClipboardCopy();
5454
const { copied: htmlCopied, copy: copyHtml } = useClipboardCopy();
55-
const { copied: badgeCopied } = useClipboardCopy();
5655
const [badgeDialogOpen, setBadgeDialogOpen] = useState(false);
5756
const [badgeStyle, setBadgeStyle] = useState<"flat" | "flat-square" | "gradient">("flat-square");
5857

@@ -71,8 +70,14 @@ export function UserProfileClient({ user, location, countryParam }: Props) {
7170
const badgeUrl =
7271
`https://img.shields.io/badge/${esc("DevImpact Score")}-${esc(score.toFixed(1))}-${color}` +
7372
`?style=${shieldStyle}&logo=github`;
73+
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL;
74+
let origin = "";
75+
if (siteUrl) {
76+
origin = siteUrl.endsWith("/") ? siteUrl.slice(0, -1) : siteUrl;
77+
} else if (typeof window !== "undefined") {
78+
origin = window.location.origin;
79+
}
7480

75-
const origin = typeof window !== "undefined" ? window.location.origin : "";
7681
const profileUrl = `${origin}/user/${encodeURIComponent(user.username)}`;
7782

7883
return {
@@ -328,22 +333,11 @@ export function UserProfileClient({ user, location, countryParam }: Props) {
328333
variant="secondary"
329334
size="md"
330335
onClick={() => setBadgeDialogOpen(true)}
331-
className="col-span-2 flex w-full items-center justify-center gap-1.5 px-3 text-xs sm:col-span-1 sm:w-auto sm:px-4 sm:text-sm"
336+
className="col-span-2 flex w-full items-center justify-center gap-1.5 whitespace-nowrap px-3 text-xs sm:col-span-1 sm:w-auto sm:px-4 sm:text-sm"
332337
aria-label={t("profile.getBadge")}
333338
>
334-
{badgeCopied ? (
335-
<>
336-
<Check className="h-4 w-4 shrink-0 text-green-500" />
337-
338-
<span className="truncate text-green-500">{t("profile.badgeCopied")}</span>
339-
</>
340-
) : (
341-
<>
342-
<BadgeCheck className="h-4 w-4 shrink-0" />
343-
344-
<span className="truncate">{t("profile.getBadge")}</span>
345-
</>
346-
)}
339+
<BadgeCheck className="h-4 w-4 shrink-0" />
340+
<span className="truncate">{t("profile.getBadge")}</span>
347341
</Button>
348342
</div>
349343
</div>

0 commit comments

Comments
 (0)