@@ -8,6 +8,7 @@ import { TutorialMdxQuery } from '../../graphqlTypes';
88import { HideOnTablet , ShowOnTablet } from '../../utils/responsive' ;
99import { Flex , Box } from '../shared/base' ;
1010import { optionalChaining } from '../../utils/helpers' ;
11+ import ChapterMutation from '../ChapterMutation' ;
1112
1213type TutorialLayoutProps = { data : TutorialMdxQuery } & RouterProps ;
1314
@@ -19,6 +20,10 @@ const TutorialLayout: React.FunctionComponent<TutorialLayoutProps> = ({
1920 return null ;
2021 }
2122 const { pageTitle } = data ! . mdx ! . frontmatter ! ;
23+ const gatsbyID = optionalChaining (
24+ ( ) => data ! . tutorialTitle ! . frontmatter ! . id ! ,
25+ ) ;
26+
2227 const tutorialTitle = optionalChaining (
2328 ( ) => data ! . tutorialTitle ! . frontmatter ! . tutorialTitle ! ,
2429 ) ;
@@ -27,6 +32,7 @@ const TutorialLayout: React.FunctionComponent<TutorialLayoutProps> = ({
2732 data ! . pageTitles ! . edges ! . map ( a => a . node ! . frontmatter ! . pageTitle ! ) ,
2833 ) || [ ] ;
2934 const { location } = props ;
35+ const currentChapter = chapters . indexOf ( pageTitle ) + 1 ;
3036
3137 return (
3238 < Layout location = { location } >
@@ -54,6 +60,7 @@ const TutorialLayout: React.FunctionComponent<TutorialLayoutProps> = ({
5460 < ShowOnTablet >
5561 < MDXRenderer > { data ! . mdx ! . code ! . body } </ MDXRenderer >
5662 </ ShowOnTablet >
63+ < ChapterMutation gatsbyID = { gatsbyID } currentChapter = { currentChapter } />
5764 </ Layout >
5865 ) ;
5966} ;
@@ -93,6 +100,7 @@ export const pageQuery = graphql`
93100 fileAbsolutePath: { regex: $folderRegex }
94101 ) {
95102 frontmatter {
103+ id
96104 tutorialTitle
97105 }
98106 }
0 commit comments