-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgatsby-node.js
39 lines (34 loc) · 925 Bytes
/
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
const freebiesHuntApi = require("freebies-hunt-api");
const { kebabCase } = require("./src/scripts")
exports.createPages = async ({ actions: { createPage } }) => {
const { categorizedData } = freebiesHuntApi;
createPage({
path: '/',
component: require.resolve("./src/templates/categories.js"),
context: {
categories: categorizedData
}
})
for (const category in categorizedData) {
const categoryObject = categorizedData[category];
createPage({
path: `/${kebabCase(category)}`,
component: require.resolve("./src/templates/category.js"),
context: {
category: categoryObject,
name: category,
categories: categorizedData,
}
})
}
};
// adding some webpack configuration
exports.onCreateWebpackConfig = ({ actions }) => {
actions.setWebpackConfig({
node: {
fs: 'empty',
path: true,
__dirname: true
}
})
}