-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
gatsby-node.js
55 lines (51 loc) · 1.33 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
54
55
const path = require(`path`);
const _ = require("lodash");
exports.createPages = async ({ graphql, actions }) => {
const { createPage } = actions
const result = await graphql(`
query {
allBooks {
edges {
node {
author
cover
description
id
isbn
pages
published
publisher
rating
subtitle
title
topic
website
}
}
}
}
`);
result.data.allBooks.edges.forEach((edge) => {
createPage({
path: `/${_.kebabCase(edge.node.title)}/`,
component: path.resolve(`./src/templates/BookDetails.js`),
context: {
// Data passed to context is available
// in page queries as GraphQL variables.
title: edge.node.title,
},
});
/*if (edge.node.frontmatter.tags) {
edge.node.frontmatter.tags.forEach(tag => {
tagSet.add(tag);
});
}
tagSet.forEach(tag => {
createPage({
path: `/tags/${_.kebabCase(tag)}/`,
component: path.resolve(`./src/templates/tagged-post.js`),
context: { tag }
});
});*/
})
}