@@ -7,31 +7,24 @@ import UpvoteMutation from './UpvoteMutation';
7
7
import BookmarkMutation from './BookmarkMutation' ;
8
8
import ProgressBanner from './ProgressBanner' ;
9
9
import { getTutorialbyGatsbyID } from '../../utils/queries' ;
10
+ import { GetTutorialbyGatsbyIdQuery , Mdx } from '../../graphqlTypes' ;
10
11
11
12
type TutorialListingProps = {
12
- tutorial : Tutorial ;
13
- } ;
14
-
15
- type Tutorial = {
16
- id : string ;
17
- fileAbsolutePath : string ;
18
- frontmatter : FrontMatter ;
19
- } ;
20
-
21
- type FrontMatter = {
22
- id : string ;
23
- tutorialTitle : string ;
24
- description : string ;
13
+ tutorial : Mdx ;
25
14
} ;
26
15
27
16
const TutorialListing : React . FunctionComponent < TutorialListingProps > = ( {
28
17
tutorial,
29
18
} ) => {
30
- const gatsbyID = tutorial . frontmatter . id ;
31
- let tutorialPath = getTutorialOverviewSlug ( tutorial . fileAbsolutePath ) ;
19
+ const gatsbyID = tutorial ! . frontmatter ! . id ;
20
+ let tutorialPath = getTutorialOverviewSlug ( tutorial ! . fileAbsolutePath ) ;
32
21
return (
33
- < Query query = { getTutorialbyGatsbyID } variables = { { gatsbyID : gatsbyID } } >
22
+ < Query < GetTutorialbyGatsbyIdQuery >
23
+ query = { getTutorialbyGatsbyID }
24
+ variables = { { gatsbyID : gatsbyID } }
25
+ >
34
26
{ ( { data } ) => {
27
+ const gatsbyTutorial = data ! . getTutorialbyGatsbyID ;
35
28
return (
36
29
< Card
37
30
width = { [ 1 ] }
@@ -43,20 +36,19 @@ const TutorialListing: React.FunctionComponent<TutorialListingProps> = ({
43
36
>
44
37
< Flex alignItems = "center" justifyContent = "center" >
45
38
< Box width = { 1 / 12 } >
46
- { data . getTutorialbyGatsbyID && (
39
+ { gatsbyTutorial && (
47
40
< div >
48
- < UpvoteMutation tutorial = { data . getTutorialbyGatsbyID } />
49
- < BookmarkMutation tutorial = { data . getTutorialbyGatsbyID } />
50
- < ProgressBanner tutorial = { data . getTutorialbyGatsbyID } />
41
+ < UpvoteMutation tutorial = { gatsbyTutorial } />
42
+ < BookmarkMutation tutorial = { gatsbyTutorial } />
43
+ < ProgressBanner tutorial = { gatsbyTutorial } />
51
44
</ div >
52
45
) }
53
46
</ Box >
54
-
55
47
< Box width = { 11 / 12 } >
56
48
< Link to = { tutorialPath } >
57
- < Heading > { tutorial . frontmatter . tutorialTitle } </ Heading >
49
+ < Heading > { tutorial ! . frontmatter ! . tutorialTitle } </ Heading >
58
50
</ Link >
59
- < Text > { tutorial . frontmatter . description } </ Text >
51
+ < Text > { tutorial ! . frontmatter ! . description } </ Text >
60
52
</ Box >
61
53
</ Flex >
62
54
</ Card >
0 commit comments