File tree Expand file tree Collapse file tree 6 files changed +20
-24
lines changed
packages/gatsby-theme/src/components Expand file tree Collapse file tree 6 files changed +20
-24
lines changed Original file line number Diff line number Diff line change @@ -3,12 +3,12 @@ import { Mutation } from 'react-apollo';
3
3
import { loginUser } from '../../utils/auth' ;
4
4
import { BookmarkButton } from '../shared/buttons' ;
5
5
import { BookmarkTutorial } from '../../utils/queries' ;
6
+ import { BookmarkTutorialMutation } from '../../graphqlTypes' ;
6
7
import { optionalChaining } from '../../utils/helpers' ;
7
-
8
8
import { handleMutationResponse , ApiErrors } from '../../utils/errorHandling' ;
9
9
10
10
const BookmarkMutation = ( { tutorial } ) => (
11
- < Mutation
11
+ < Mutation < BookmarkTutorialMutation >
12
12
mutation = { BookmarkTutorial }
13
13
variables = { {
14
14
id : tutorial . id ,
Original file line number Diff line number Diff line change @@ -6,9 +6,13 @@ import { VoteButton } from '../shared/buttons';
6
6
import { Heading , Flex } from '../shared/base' ;
7
7
import { optionalChaining } from '../../utils/helpers' ;
8
8
import { UpvoteTutorial } from '../../utils/queries' ;
9
+ import { UpvoteTutorialMutation } from '../../graphqlTypes' ;
9
10
10
11
const UpvoteMutation = ( { tutorial } ) => (
11
- < Mutation mutation = { UpvoteTutorial } variables = { { id : tutorial . id } } >
12
+ < Mutation < UpvoteTutorialMutation >
13
+ mutation = { UpvoteTutorial }
14
+ variables = { { id : tutorial . id } }
15
+ >
12
16
{ upvote => {
13
17
let active = optionalChaining ( ( ) => tutorial . viewerUserTutorial . upvoted ) ;
14
18
let upvotes = optionalChaining ( ( ) => tutorial . upvotes ) ;
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { Query } from 'react-apollo';
4
4
import ProgressBar from '../shared/ProgressBar' ;
5
5
import { TutorialButton } from '../shared/buttons' ;
6
6
import { getTutorialbyGatsbyID } from '../../utils/queries' ;
7
- import { GetTutorialbyGatsbyIdQuery } from '../../graphqlTypes' ;
7
+ import { GetTutorialbyGatsbyIdQuery , Maybe } from '../../graphqlTypes' ;
8
8
import { getTutorialOverviewSlug } from '../../utils/getTutorialSlug' ;
9
9
import { optionalChaining , percent } from '../../utils/helpers' ;
10
10
Original file line number Diff line number Diff line change @@ -13,18 +13,6 @@ type QueryData = {
13
13
node : Mdx ;
14
14
} ;
15
15
16
- // type Node = {
17
- // id: string;
18
- // fileAbsolutePath: string;
19
- // frontmatter: Frontmatter;
20
- // };
21
-
22
- // type Frontmatter = {
23
- // id: string;
24
- // tutorialTitle: string;
25
- // description: string;
26
- // };
27
-
28
16
const CourseSection : React . FunctionComponent < CourseSectionProps > = ( {
29
17
heading,
30
18
body,
Original file line number Diff line number Diff line change @@ -15,12 +15,12 @@ interface PageTemplateProps {
15
15
}
16
16
17
17
const PageTemplate : React . FunctionComponent < PageTemplateProps > = ( { data } ) => {
18
- let gatsbyID = optionalChaining ( ( ) => data . overview . frontmatter . id ) ;
18
+ let gatsbyID = optionalChaining ( ( ) => data ! . overview ! . frontmatter ! . id ) ;
19
19
20
20
// This is so that the start button can link to the user's current path
21
21
// TO DO find a better way to pass in the which chapter the user is currently on
22
22
const chapterPaths = optionalChaining ( ( ) =>
23
- data . allMdx . edges . map ( a =>
23
+ data ! . allMdx ! . edges . map ( a =>
24
24
getTutorialSlug ( optionalChaining ( ( ) => a . node . fileAbsolutePath ) ) ,
25
25
) ,
26
26
) ;
@@ -29,11 +29,11 @@ const PageTemplate: React.FunctionComponent<PageTemplateProps> = ({ data }) => {
29
29
< Layout >
30
30
< Content >
31
31
< Flex >
32
- < Box width = { 3 / 4 } aligncontent = "center" >
32
+ < Box width = { 3 / 4 } >
33
33
< TutorialHeader
34
34
width = { 1 / 2 }
35
- title = { data ! . overview ! . frontmatter ! . tutorialTitle }
36
- description = { data ! . overview ! . frontmatter ! . description }
35
+ title = { data ! . overview ! . frontmatter ! . tutorialTitle || 'blank' }
36
+ description = { data ! . overview ! . frontmatter ! . description || 'blank' }
37
37
tags = { [ 'React' , 'Apollo' , 'Javascript' ] }
38
38
/>
39
39
</ Box >
Original file line number Diff line number Diff line change @@ -6,7 +6,11 @@ import { SpectrumButton } from '../shared/buttons';
6
6
7
7
type SidebarProps = {
8
8
tutorialTitle : string ;
9
- chapters : string [ ] ;
9
+ chapters : Chapter ;
10
+ } ;
11
+ type Chapter = {
12
+ chapterTitle : string ;
13
+ chapterPath : string ;
10
14
} ;
11
15
12
16
export const Sidebar : React . FunctionComponent < SidebarProps > = ( {
@@ -22,8 +26,8 @@ export const Sidebar: React.FunctionComponent<SidebarProps> = ({
22
26
</ Card >
23
27
< ul >
24
28
{ chapters . map ( chapter => (
25
- < li key = { chapter . chapterTitle } >
26
- < a href = { chapter . chapterPath } > { chapter . chapterTitle } </ a >
29
+ < li key = { chapter ! . chapterTitle } >
30
+ < a href = { chapter ! . chapterPath } > { chapter ! . chapterTitle } </ a >
27
31
</ li >
28
32
) ) }
29
33
</ ul >
You can’t perform that action at this time.
0 commit comments