@@ -9,6 +9,8 @@ import { Quote } from "../ui/molecules/quote";
9
9
10
10
import "./index.scss" ;
11
11
import { useLocale } from "../hooks" ;
12
+ import { PageNotFound } from "../page-not-found" ;
13
+ import { Loading } from "../ui/atoms/loading" ;
12
14
13
15
type ContributorDetails = {
14
16
sections : [ string ] ;
@@ -31,7 +33,7 @@ export function ContributorSpotlight(props: HydrationData<ContributorDetails>) {
31
33
32
34
const fallbackData = props . hyData ? props : undefined ;
33
35
34
- const { data : { hyData } = { } } = useSWR < any > (
36
+ const { error , data : { hyData } = { } } = useSWR < any > (
35
37
contributorJSONUrl ,
36
38
async ( url ) => {
37
39
const response = await fetch ( url ) ;
@@ -55,37 +57,39 @@ export function ContributorSpotlight(props: HydrationData<ContributorDetails>) {
55
57
document . title = pageTitle ;
56
58
} , [ hyData ] ) ;
57
59
60
+ if ( error ) {
61
+ return < PageNotFound /> ;
62
+ } else if ( ! hyData ) {
63
+ return < Loading /> ;
64
+ }
65
+
58
66
return (
59
67
< >
60
68
< main className = "contributor-spotlight-content-container" >
61
- { hyData && (
62
- < >
63
- < h1 className = "_ify" > Contributor profile</ h1 >
64
- < section className = "profile-header" >
65
- < img
66
- className = "profile-image"
67
- src = { `${ baseURL } /${ hyData . profileImg } ` }
68
- alt = { hyData . profileImgAlt }
69
- width = "200"
70
- height = "200"
71
- />
72
- < a
73
- className = "username"
74
- href = { `https://github.com/${ hyData . usernames . github } ` }
75
- >
76
- @{ hyData . usernames . github }
77
- </ a >
78
- </ section >
79
- < section
80
- dangerouslySetInnerHTML = { { __html : hyData . sections [ 0 ] } }
81
- > </ section >
82
- < Quote name = { hyData . contributorName } > { hyData . quote } </ Quote >
69
+ < h1 className = "_ify" > Contributor profile</ h1 >
70
+ < section className = "profile-header" >
71
+ < img
72
+ className = "profile-image"
73
+ src = { `${ baseURL } /${ hyData . profileImg } ` }
74
+ alt = { hyData . profileImgAlt }
75
+ width = "200"
76
+ height = "200"
77
+ />
78
+ < a
79
+ className = "username"
80
+ href = { `https://github.com/${ hyData . usernames . github } ` }
81
+ >
82
+ @{ hyData . usernames . github }
83
+ </ a >
84
+ </ section >
85
+ < section
86
+ dangerouslySetInnerHTML = { { __html : hyData . sections [ 0 ] } }
87
+ > </ section >
88
+ < Quote name = { hyData . contributorName } > { hyData . quote } </ Quote >
83
89
84
- { hyData . sections . slice ( 1 ) . map ( ( section ) => {
85
- return < section dangerouslySetInnerHTML = { { __html : section } } /> ;
86
- } ) }
87
- </ >
88
- ) }
90
+ { hyData . sections . slice ( 1 ) . map ( ( section ) => {
91
+ return < section dangerouslySetInnerHTML = { { __html : section } } /> ;
92
+ } ) }
89
93
</ main >
90
94
< GetInvolved />
91
95
</ >
0 commit comments