Skip to content

Commit d6bfdec

Browse files
committed
add links to individual chapters from overpage
1 parent e07cb95 commit d6bfdec

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

packages/gatsby-theme/src/components/Chapter.tsx

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,37 @@
11
import React from 'react';
2+
import { getTutorialSlug } from '../utils/getTutorialSlug';
3+
import { Link } from 'gatsby';
24
import { Heading, Text, Flex, Card } from './shared/base';
35

46
type ChapterProps = {
57
num: string | number;
6-
title: string | null;
7-
description: string | null;
8+
tutorial: Tutorial;
9+
};
10+
11+
type Tutorial = {
12+
id: string;
13+
fileAbsolutePath: string;
14+
frontmatter: FrontMatter;
815
};
916

17+
type FrontMatter = {
18+
pageTitle: string | null;
19+
description: string | null;
20+
}
21+
1022
const Chapter: React.FunctionComponent<ChapterProps> = ({
11-
num,
12-
title,
13-
description,
23+
num, tutorial
1424
}) => {
1525
return (
1626
<Card width={[1]} p={4} my={4} borderRadius={8} boxShadow="small">
1727
<Flex alignItems="center">
1828
<Heading p={4}>{num}</Heading>
1929
<div>
20-
<Heading as="h2">{title}</Heading>
21-
<Text>{description}</Text>
30+
<Link to={getTutorialSlug(tutorial.fileAbsolutePath)}>
31+
<Heading as="h2">{tutorial.frontmatter.pageTitle}</Heading>
32+
</Link>
33+
<Text>{tutorial.frontmatter.description}</Text>
34+
2235
</div>
2336
</Flex>
2437
</Card>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ const PageTemplate: React.FunctionComponent<PageTemplateProps> = ({ data }) => {
4848
<div>
4949
<Chapter
5050
num={num < 10 ? `0${num}` : num}
51-
title={mdx.node.frontmatter!.pageTitle}
52-
description={mdx.node.frontmatter!.description}
51+
tutorial = {mdx.node}
5352
/>
5453
</div>
5554
);
@@ -73,6 +72,7 @@ export const query = graphql`
7372
edges {
7473
node {
7574
id
75+
fileAbsolutePath
7676
frontmatter {
7777
pageTitle
7878
description

0 commit comments

Comments
 (0)