@@ -14,12 +14,22 @@ import { getTutorialOverviewSlug } from '../utils/getTutorialSlug';
1414import ProgressBar from '../components/ProgressBar' ;
1515
1616const 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+ ] ;
2333 return (
2434 < Layout >
2535 < Content >
@@ -28,59 +38,78 @@ const courses = data => {
2838 A general introduction to GraphQL for frontend and backend developers.
2939 </ Text >
3040 < Text >
31- { ' ' }
3241 Read this tutorial to learn about GraphQL's basic concepts and prepare
3342 yourself for a hands-on beginner tutorial.
3443 </ 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+ ) ) }
7649 </ Content >
7750 </ Layout >
7851 ) ;
7952} ;
8053
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+ } ) => {
82111 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 ] } >
84113 < Flex flexDirection = "column" alignItems = "center" justifyContent = "center" >
85114 < Image
86115 width = { [ 0.5 , 0.5 , 0.5 ] }
0 commit comments