File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change 11---
22import { REPO , getCommitInfo } from " ../../utils/git" ;
3+ import { Image } from " astro:assets" ;
34
45const { lang, lastUpdated } = Astro .locals .starlightRoute ;
56const filePath = Astro .locals .starlightRoute .entry .filePath ;
@@ -21,7 +22,20 @@ const info = await getCommitInfo(filePath);
2122 </span >{ " " }
2223 { info && (
2324 <span class = " nowrap" >
24- by <a href = { info .committer .href } >{ info .committer .name } </a >
25+ by{ " " }
26+ <a href = { info .committer .href } >
27+ { info .committer .avatar && (
28+ <Image
29+ src = { info .committer .avatar }
30+ alt = { info .committer .name }
31+ class = " avatar"
32+ width = " 18"
33+ height = " 18"
34+ loading = " lazy"
35+ />
36+ )}
37+ { info .committer .name }
38+ </a >{ " " }
2539 in <a href = { ` https://github.com/${REPO }/commit/${info .hash } ` } >{ info .hash .substring (0 , 7 )} </a >
2640 </span >
2741 )}
@@ -38,4 +52,11 @@ const info = await getCommitInfo(filePath);
3852 .nowrap {
3953 white-space: nowrap;
4054 }
55+
56+ .avatar {
57+ vertical-align: middle;
58+ border-radius: 50%;
59+ margin-left: 1px;
60+ margin-right: 4px;
61+ }
4162</style >
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { execSync } from "child_process";
33export interface CommitterInfo {
44 name : string ;
55 href : string ;
6+ avatar ?: string ;
67}
78
89export interface CommitInfo {
@@ -47,6 +48,7 @@ export const getCommitInfo = async (filePath: string): Promise<CommitInfo | null
4748 if ( res . ok ) {
4849 const commit = await res . json ( ) ;
4950 info . href = commit . author . html_url ;
51+ info . avatar = commit . author . avatar_url ;
5052 }
5153
5254 cache . set ( email , info ) ;
You can’t perform that action at this time.
0 commit comments