-
Notifications
You must be signed in to change notification settings - Fork 20
/
gatsby-node.js
53 lines (50 loc) · 1.47 KB
/
gatsby-node.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
exports.createPages = async ({ actions, graphql, reporter }) => {
const result = await graphql(`
query {
allMdx {
nodes {
frontmatter {
slug
type
filterBy
}
}
}
}
`);
if (result.errors) {
reporter.panic('failed to create chapter', result.errors);
}
const mdxFiles = result.data.allMdx.nodes;
mdxFiles.forEach(file => {
console.log(file.frontmatter.filterBy);
if (file.frontmatter.type === 'module') {
actions.createPage({
path: `/tezos/academy/${file.frontmatter.slug}`,
component: require.resolve('./src/templates/overview.js'),
context: {
slug: file.frontmatter.slug,
},
});
} else if (file.frontmatter.filterBy === 'module-04') {
console.log('Creating file for taquito');
actions.createPage({
path: `/tezos/academy/${file.frontmatter.filterBy}/${file.frontmatter.slug}`,
component: require.resolve('./src/templates/chapterWithLiveEditor.js'),
context: {
slug: file.frontmatter.slug,
module: file.frontmatter.filterBy,
},
});
} else {
actions.createPage({
path: `/tezos/academy/${file.frontmatter.filterBy}/${file.frontmatter.slug}`,
component: require.resolve('./src/templates/chapter-new.js'),
context: {
slug: file.frontmatter.slug,
module: file.frontmatter.filterBy,
},
});
}
});
};