Skip to content

Commit 08d7fa3

Browse files
committed
create current chapter variable
1 parent 9f006af commit 08d7fa3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/gatsby-theme/src/components/templates/Tutorial.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { TutorialMdxQuery } from '../../graphqlTypes';
88
import { HideOnTablet, ShowOnTablet } from '../../utils/responsive';
99
import { Flex, Box } from '../shared/base';
1010
import { optionalChaining } from '../../utils/helpers';
11+
import { Button } from '../shared/base';
1112

1213
type TutorialLayoutProps = { data: TutorialMdxQuery } & RouterProps;
1314

@@ -28,6 +29,8 @@ const TutorialLayout: React.FunctionComponent<TutorialLayoutProps> = ({
2829
) || [];
2930
const { location } = props;
3031

32+
const currentChapterNumber = chapters.indexOf(pageTitle) + 1;
33+
3134
return (
3235
<Layout location={location}>
3336
<ShowOnTablet>
@@ -54,6 +57,10 @@ const TutorialLayout: React.FunctionComponent<TutorialLayoutProps> = ({
5457
<ShowOnTablet>
5558
<MDXRenderer>{data!.mdx!.code!.body}</MDXRenderer>
5659
</ShowOnTablet>
60+
<Button onClick={() => console.log(currentChapterNumber)}>
61+
{' '}
62+
Next Chapter
63+
</Button>
5764
</Layout>
5865
);
5966
};

0 commit comments

Comments
 (0)