@@ -14,12 +14,22 @@ import { getTutorialOverviewSlug } from '../utils/getTutorialSlug';
14
14
import ProgressBar from '../components/ProgressBar' ;
15
15
16
16
const courses = data => {
17
- console . log ( data ) ;
18
- let frontend = data . data . frontend . edges ;
19
- let backend = data . data . backend . edges ;
20
- console . log ( frontend ) ;
21
- console . log ( backend ) ;
22
-
17
+ const courseSectionData = [
18
+ {
19
+ heading : `Frontend` ,
20
+ body : `Implement a web frontend for a Hacker News app that talks to a GraphQL
21
+ API. We provide a hosted GraphQL API for you so that you can test your
22
+ app in a real world environment.` ,
23
+ data : data . data . frontend . edges ,
24
+ } ,
25
+ {
26
+ heading : `Backend` ,
27
+ body : `Implement a GraphQL API that's backed by a database. The tutorial
28
+ teach schema design and implement features like authentication,
29
+ filtering, pagination and a lot more` ,
30
+ data : data . data . backend . edges ,
31
+ } ,
32
+ ] ;
23
33
return (
24
34
< Layout >
25
35
< Content >
@@ -28,59 +38,78 @@ const courses = data => {
28
38
A general introduction to GraphQL for frontend and backend developers.
29
39
</ Text >
30
40
< Text >
31
- { ' ' }
32
41
Read this tutorial to learn about GraphQL's basic concepts and prepare
33
42
yourself for a hands-on beginner tutorial.
34
43
</ Text >
35
- < Flex m = { [ 1 , 1 , 1 ] } >
36
- < Box width = { [ 0.2 , 0.2 , 0.2 ] } >
37
- < Heading > Frontend </ Heading >
38
- < Text >
39
- Implement a web frontend for a Hacker News app that talks to a
40
- GraphQL API. We provide a hosted GraphQL API for you so that you
41
- can test your app in a real world environment.
42
- </ Text >
43
- </ Box >
44
- < Box width = { [ 0.8 , 0.8 , 0.8 ] } >
45
- < Flex alignItems = "top" justifyContent = "center" flexWrap = "wrap" >
46
- { frontend . map ( tutorial => (
47
- < CourseCard
48
- tutorialTitle = { tutorial . node . frontmatter . tutorialTitle }
49
- fileAbsolutePath = { tutorial . node . fileAbsolutePath }
50
- />
51
- ) ) }
52
- </ Flex >
53
- </ Box >
54
- </ Flex >
55
-
56
- < Flex m = { [ 1 , 1 , 1 ] } >
57
- < Box width = { [ 0.2 , 0.2 , 0.2 ] } >
58
- < Heading > Backend </ Heading >
59
- < Text >
60
- Implement a GraphQL API that's backed by a database. The tutorial
61
- teach schema design and implement features like authentication,
62
- filtering, pagination and a lot more
63
- </ Text >
64
- </ Box >
65
- < Box width = { [ 0.8 , 0.8 , 0.8 ] } >
66
- < Flex alignItems = "top" justifyContent = "center" flexWrap = "wrap" >
67
- { backend . map ( tutorial => (
68
- < CourseCard
69
- tutorialTitle = { tutorial . node . frontmatter . tutorialTitle }
70
- fileAbsolutePath = { tutorial . node . fileAbsolutePath }
71
- />
72
- ) ) }
73
- </ Flex >
74
- </ Box >
75
- </ Flex >
44
+ { courseSectionData . map ( section => (
45
+ < div key = { section . heading } >
46
+ < CourseSection { ...section } />
47
+ </ div >
48
+ ) ) }
76
49
</ Content >
77
50
</ Layout >
78
51
) ;
79
52
} ;
80
53
81
- const CourseCard = ( { tutorialTitle, fileAbsolutePath } ) => {
54
+ type CourseSectionProps = {
55
+ heading : string ;
56
+ body : string ;
57
+ data : [ QueryData ] ;
58
+ } ;
59
+
60
+ type QueryData = {
61
+ node : Node ;
62
+ } ;
63
+
64
+ type Node = {
65
+ id : string ;
66
+ fileAbsolutePath : string ;
67
+ frontmatter : Frontmatter ;
68
+ } ;
69
+
70
+ type Frontmatter = {
71
+ tutorialTitle : string ;
72
+ description : string ;
73
+ } ;
74
+
75
+ const CourseSection : React . FunctionComponent < CourseSectionProps > = ( {
76
+ heading,
77
+ body,
78
+ data,
79
+ } ) => {
80
+ return (
81
+ < Flex m = { [ 1 , 1 , 1 ] } >
82
+ < Box width = { [ 0.2 , 0.2 , 0.2 ] } >
83
+ < Heading > { heading } </ Heading >
84
+ < Text > { body } </ Text >
85
+ </ Box >
86
+ < Box width = { [ 0.8 , 0.8 , 0.8 ] } >
87
+ < Flex alignItems = "top" justifyContent = "center" flexWrap = "wrap" >
88
+ { data . map ( tutorial => (
89
+ < Box width = { [ 1 , 0.8 , 0.4 ] } key = { tutorial . node . id } >
90
+ < CourseCard
91
+ tutorialTitle = { tutorial . node . frontmatter . tutorialTitle }
92
+ fileAbsolutePath = { tutorial . node . fileAbsolutePath }
93
+ />
94
+ </ Box >
95
+ ) ) }
96
+ </ Flex >
97
+ </ Box >
98
+ </ Flex >
99
+ ) ;
100
+ } ;
101
+
102
+ type CourseCardProps = {
103
+ tutorialTitle : string ;
104
+ fileAbsolutePath : string ;
105
+ } ;
106
+
107
+ const CourseCard : React . FunctionComponent < CourseCardProps > = ( {
108
+ tutorialTitle,
109
+ fileAbsolutePath,
110
+ } ) => {
82
111
return (
83
- < Card m = { [ 2 , 2 , 2 ] } p = { [ 2 , 2 , 2 ] } width = { [ 1 / 2 , 1 / 2 , 1 / 4 ] } >
112
+ < Card m = { [ 1 , 1 , 1 ] } p = { [ 2 , 2 , 2 ] } >
84
113
< Flex flexDirection = "column" alignItems = "center" justifyContent = "center" >
85
114
< Image
86
115
width = { [ 0.5 , 0.5 , 0.5 ] }
0 commit comments