@@ -16,26 +16,22 @@ export const getServerSideProps = async (
1616) : Promise < GetServerSidePropsResult < Props > > => {
1717 const user = context . params ?. user ;
1818
19- if ( typeof user = == 'string' ) {
20- const res = await fetch ( `https://github-contributions-api.deno.dev/ ${ user } .json` ) ;
21- const json = await res . json ( ) ;
19+ if ( typeof user ! == 'string' ) {
20+ return { notFound : true } ;
21+ }
2222
23- const contributions = json . contributions
24- . flat ( )
25- . reverse ( )
26- . map ( ( c : { contributionCount : number } ) => c . contributionCount ) ;
23+ const res = await fetch ( `https://github-contributions-api.deno.dev/${ user } .json` ) ;
24+ const json = await res . json ( ) ;
2725
28- const [ todayContributionCount , yesterdayContributionCount ] = contributions ;
29- const currentStreak = todayContributionCount > 0 ? contributions . indexOf ( 0 ) : contributions . slice ( 1 ) . indexOf ( 0 ) ;
26+ const contributions = json . contributions
27+ . flat ( )
28+ . reverse ( )
29+ . map ( ( c : { contributionCount : number } ) => c . contributionCount ) ;
3030
31- return {
32- props : { user, todayContributionCount, yesterdayContributionCount, currentStreak } ,
33- } ;
34- } else {
35- return {
36- notFound : true ,
37- } ;
38- }
31+ const [ todayContributionCount , yesterdayContributionCount ] = contributions ;
32+ const currentStreak = todayContributionCount > 0 ? contributions . indexOf ( 0 ) : contributions . slice ( 1 ) . indexOf ( 0 ) ;
33+
34+ return { props : { user, todayContributionCount, yesterdayContributionCount, currentStreak } } ;
3935} ;
4036
4137const fetchFunc = async ( userId : string ) => {
0 commit comments