Skip to content

Commit 466060b

Browse files
committed
feat: make pull request titles clickable links to GitHub PR
closes #61 Add clickable links to PR titles in the Top Work section: - Add title and url fields to GraphQL query for pull requests - Map actual PR title (was incorrectly using repo nameWithOwner) - Render PR titles as anchor tags linking to the PR on GitHub - Opens in new tab with rel=noopener for security
1 parent fd084c5 commit 466060b

5 files changed

Lines changed: 23 additions & 2 deletions

File tree

components/top-list.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type Props = {
2727
export function TopList({ userResults }: Props) {
2828
const cardDetails = (data: {
2929
title: string;
30+
titleUrl?: string;
3031
subtitle?: string;
3132
score?: number;
3233
badges: { tooltip?: string; label?: any; icon: any }[];
@@ -37,7 +38,20 @@ export function TopList({ userResults }: Props) {
3738
key={data.key}
3839
>
3940
<div>
40-
<div className="font-medium text-slate-900">{data.title}</div>
41+
<div className="font-medium text-slate-900">
42+
{data.titleUrl ? (
43+
<a
44+
href={data.titleUrl}
45+
target="_blank"
46+
rel="noopener noreferrer"
47+
className="hover:underline text-primary"
48+
>
49+
{data.title}
50+
</a>
51+
) : (
52+
data.title
53+
)}
54+
</div>
4155
<div className="text-xs text-muted-foreground mt-1">
4256
{data.subtitle}
4357
</div>
@@ -125,6 +139,7 @@ export function TopList({ userResults }: Props) {
125139
cardDetails({
126140
key: `pr-${i}`,
127141
title: pr.title || "Untitled Pull Request",
142+
titleUrl: pr.url,
128143
subtitle: `in ${pr.repo}`,
129144
score: pr.score,
130145
badges: [

lib/github.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ const QUERY = /* GraphQL */ `
3939
merged
4040
additions
4141
deletions
42+
title
43+
url
4244
repository {
4345
nameWithOwner
4446
stargazerCount

lib/score.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ export function calculateUserScore(
114114
})),
115115
topPullRequests: prScore.details.slice(0, 3).map((item) => ({
116116
repo: item.pr.repository.nameWithOwner,
117-
title: item.pr.repository.nameWithOwner,
117+
title: item.pr.title,
118+
url: item.pr.url,
118119
stars: item.pr.repository.stargazerCount,
119120
score: item.score,
120121
additions: item.pr.additions,

types/github.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export type PullRequestNode = {
1010
merged: boolean;
1111
additions: number;
1212
deletions: number;
13+
title: string;
14+
url: string;
1315
repository: {
1416
nameWithOwner: string;
1517
stargazerCount: number;

types/user-result.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export type UserResult = {
1616
stars?: number;
1717
score?: number;
1818
title?: string;
19+
url?: string;
1920
deletions?: number;
2021
additions?: number;
2122
}[];

0 commit comments

Comments
 (0)