@@ -20,11 +20,11 @@ type HacktoberfestData = [
2020 github : {
2121 handle : string ;
2222 nbContributions : number ;
23- } ;
23+ } | null ;
2424 gitlab : {
2525 handle : string ;
2626 nbContributions : number ;
27- } ;
27+ } | null ;
2828 } ,
2929] [ ] ;
3030
@@ -44,18 +44,31 @@ async function getHacktoberfestData(): Promise<HacktoberfestData> {
4444}
4545
4646function transformToContributors ( data : HacktoberfestData ) : Contributor [ ] {
47- return data . map ( ( [ id , contributor ] ) => ( {
48- id,
49- name : contributor . name ,
50- avatarUrl : `https://github.com/${ contributor . github . handle } .png?size=40` ,
51- imageHint : 'avatar person' ,
52- prCount : contributor . github . nbContributions ,
53- mrCount : contributor . gitlab . nbContributions ,
54- totalContributions :
55- contributor . github . nbContributions + contributor . gitlab . nbContributions ,
56- githubHandle : contributor . github . handle ,
57- gitlabHandle : contributor . gitlab . handle ,
58- } ) ) ;
47+ return data . map ( ( [ id , contributor ] ) => {
48+ const prCount = contributor . github ?. nbContributions ?? 0 ;
49+ const mrCount = contributor . gitlab ?. nbContributions ?? 0 ;
50+ const githubHandle = contributor . github ?. handle ;
51+ const gitlabHandle = contributor . gitlab ?. handle ;
52+
53+ // Use GitHub avatar if available, otherwise use GitLab avatar, or fallback to a default
54+ const avatarUrl = githubHandle
55+ ? `https://github.com/${ githubHandle } .png?size=40`
56+ : gitlabHandle
57+ ? `https://gitlab.com/${ gitlabHandle } /avatar?size=40`
58+ : null ;
59+
60+ return {
61+ id,
62+ name : contributor . name ,
63+ avatarUrl,
64+ imageHint : 'avatar person' ,
65+ prCount,
66+ mrCount,
67+ totalContributions : prCount + mrCount ,
68+ githubHandle,
69+ gitlabHandle,
70+ } ;
71+ } ) ;
5972}
6073
6174const getContributors = async ( ) : Promise < Contributor [ ] > => {
0 commit comments