Skip to content

Commit 4d1a378

Browse files
Ai-chan-0411O2sa
authored andcommitted
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 bdb0908 commit 4d1a378

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
@@ -28,6 +28,7 @@ type Props = {
2828
export function TopList({ userResults }: Props) {
2929
const cardDetails = (data: {
3030
title: string;
31+
titleUrl?: string;
3132
subtitle?: string;
3233
score?: number;
3334
badges: { tooltip?: string; label?: ReactNode; icon: ReactNode }[];
@@ -38,7 +39,20 @@ export function TopList({ userResults }: Props) {
3839
key={data.key}
3940
>
4041
<div>
41-
<div className="font-medium text-slate-900">{data.title}</div>
42+
<div className="font-medium text-slate-900">
43+
{data.titleUrl ? (
44+
<a
45+
href={data.titleUrl}
46+
target="_blank"
47+
rel="noopener noreferrer"
48+
className="hover:underline text-primary"
49+
>
50+
{data.title}
51+
</a>
52+
) : (
53+
data.title
54+
)}
55+
</div>
4256
<div className="text-xs text-muted-foreground mt-1">
4357
{data.subtitle}
4458
</div>
@@ -126,6 +140,7 @@ export function TopList({ userResults }: Props) {
126140
cardDetails({
127141
key: `pr-${i}`,
128142
title: pr.title || "Untitled Pull Request",
143+
titleUrl: pr.url,
129144
subtitle: `in ${pr.repo}`,
130145
score: pr.score,
131146
badges: [

lib/github.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ const QUERY = /* GraphQL */ `
4949
merged
5050
additions
5151
deletions
52+
title
53+
url
5254
repository {
5355
nameWithOwner
5456
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
@@ -18,6 +18,7 @@ export type UserResult = {
1818
stars?: number;
1919
score?: number;
2020
title?: string;
21+
url?: string;
2122
deletions?: number;
2223
additions?: number;
2324
}[];

0 commit comments

Comments
 (0)