Skip to content

Commit 2bce4eb

Browse files
Add "Merged by" info, syntax highlighting in comments
1 parent e61f548 commit 2bce4eb

File tree

2 files changed

+39
-29
lines changed

2 files changed

+39
-29
lines changed

src/lib/octokit.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,19 @@ import { persisted } from "svelte-persisted-store";
55
import { plainTextSerializer } from "./stores";
66
import { tokenKey } from "./types";
77

8+
let octokit: Octokit;
9+
810
/**
9-
* Creates an Octokit instance with the current user's access token.
11+
* Creates or returns a shared {@link Octokit} instance with the current user's access token.
1012
* If the user is not logged in, the new instance will be created without authentication.
1113
* In development mode, the instance will be created with the access token
1214
* from the environment if it is available, overriding the user's access token.
1315
*/
1416
export function getOctokit() {
17+
if (octokit) return octokit;
1518
// TODO: Invert the condition to make the logged in token take precedence over the environment token
1619
const hasTokenInDev = dev && !!env.PUBLIC_GITHUB_TOKEN;
17-
const octokit = new Octokit(
20+
octokit = new Octokit(
1821
hasTokenInDev
1922
? {
2023
auth: env.PUBLIC_GITHUB_TOKEN

src/routes/[pullOrIssue=poi]/[org]/[repo]/[id=number]/PageRenderer.svelte

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -79,33 +79,39 @@
7979
});
8080
8181
let rightPartInfo = $derived.by(() => {
82-
if (info) {
83-
return [
84-
...(info.closed_at
85-
? [
86-
{
87-
title: "merged" in info && info.merged ? "Merged at" : "Closed at",
88-
value: formatToDateTime(info.closed_at)
89-
}
90-
]
91-
: []),
92-
{ title: "Assignees", value: info.assignees?.map(a => a.login).join(", ") || "None" },
93-
...("requested_reviewers" in info
94-
? [
95-
{
96-
title: "Reviewers",
97-
value: info.requested_reviewers?.map(r => r.login).join(", ") || "None"
98-
}
99-
]
100-
: []),
101-
{
102-
title: "Labels",
103-
value: info.labels?.map(l => (typeof l === "string" ? l : l.name)).join(", ") || "None"
104-
},
105-
{ title: "Milestone", value: info.milestone?.title || "None" }
106-
];
107-
}
108-
return [];
82+
if (!info) return [];
83+
return [
84+
...(info.closed_at
85+
? [
86+
{
87+
title: "merged" in info && info.merged ? "Merged at" : "Closed at",
88+
value: formatToDateTime(info.closed_at)
89+
}
90+
]
91+
: []),
92+
...(info.closed_at && "merged" in info && info.merged
93+
? [
94+
{
95+
title: "Merged by",
96+
value: info.merged_by?.name ?? info.merged_by?.login ?? "Unknown"
97+
}
98+
]
99+
: []),
100+
{ title: "Assignees", value: info.assignees?.map(a => a.login).join(", ") || "None" },
101+
...("requested_reviewers" in info
102+
? [
103+
{
104+
title: "Reviewers",
105+
value: info.requested_reviewers?.map(r => r.login).join(", ") || "None"
106+
}
107+
]
108+
: []),
109+
{
110+
title: "Labels",
111+
value: info.labels?.map(l => (typeof l === "string" ? l : l.name)).join(", ") || "None"
112+
},
113+
{ title: "Milestone", value: info.milestone?.title || "None" }
114+
];
109115
});
110116
</script>
111117

@@ -291,6 +297,7 @@
291297
markdown={comment.body || "_Empty comment_"}
292298
parseRawHtml
293299
class="w-full"
300+
additionalPlugins={[shikiPlugin]}
294301
/>
295302
</div>
296303
</div>

0 commit comments

Comments
 (0)