Skip to content

Commit 268e74b

Browse files
Ai-chan-0411claude
andcommitted
feat: make pull request titles clickable links to GitHub PR
Add `title` and `url` fields to the GitHub GraphQL pullRequests query, pass them through the type system and scoring logic, and wrap PR titles in the TopList component with anchor tags linking to the GitHub PR page. Also fixes a pre-existing bug where PR titles incorrectly displayed the repository name instead of the actual pull request title. Closes #61 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a6b0119 commit 268e74b

5 files changed

Lines changed: 19 additions & 3 deletions

File tree

components/top-list.tsx

Lines changed: 11 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+
url?: string;
3031
subtitle?: string;
3132
score?: number;
3233
badges: { tooltip?: string; label?: any; icon: any }[];
@@ -37,7 +38,15 @@ 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.url ? (
43+
<a href={data.url} target="_blank" rel="noopener noreferrer" className="hover:underline">
44+
{data.title}
45+
</a>
46+
) : (
47+
data.title
48+
)}
49+
</div>
4150
<div className="text-xs text-muted-foreground mt-1">
4251
{data.subtitle}
4352
</div>
@@ -125,6 +134,7 @@ export function TopList({ userResults }: Props) {
125134
cardDetails({
126135
key: `pr-${i}`,
127136
title: pr.title || "Untitled Pull Request",
137+
url: pr.url,
128138
subtitle: `in ${pr.repo}`,
129139
score: pr.score,
130140
badges: [

lib/github.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ const QUERY = /* GraphQL */ `
3636
orderBy: { field: CREATED_AT, direction: DESC }
3737
) {
3838
nodes {
39+
title
40+
url
3941
merged
4042
additions
4143
deletions

lib/score.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export function calculateUserScore(
8989
contributionScore: number;
9090
finalScore: number;
9191
topRepos: { name: string; stars: number; forks: number; score: number }[];
92-
topPullRequests: { repo: string; stars: number; score: number }[];
92+
topPullRequests: { repo: string; title: string; url: string; stars: number; score: number }[];
9393
} {
9494
const repoScore = calculateRepoScore(data.repos);
9595
const prScore = calculatePRScore(data.pullRequests, username);
@@ -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
@@ -7,6 +7,8 @@ export type RepoNode = {
77
};
88

99
export type PullRequestNode = {
10+
title: string;
11+
url: string;
1012
merged: boolean;
1113
additions: number;
1214
deletions: 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)