-
Notifications
You must be signed in to change notification settings - Fork 168
/
Copy pathgatsby-node.js
42 lines (34 loc) · 1.08 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
const DEPLOY_ENV = process.env.DEPLOY_ENV || 'lbn_published_production';
/**
* Generate node edges
*
* @param {any} { node, actions, getNode }
*/
exports.onCreateNode = ({ node, actions }) => {
const { createNodeField } = actions;
/**
* If these don't exist, the LBN WordPress Plugin isn't installed – so build all posts.
*/
if (
!Object.prototype.hasOwnProperty.call(node, 'meta') ||
!Object.prototype.hasOwnProperty.call(node.meta, 'lbn_published_production')
) {
createNodeField({ node, name: 'deploy', value: true });
return;
}
let deploy;
if (node.meta[DEPLOY_ENV]) {
deploy = true;
} else {
deploy = false;
}
createNodeField({ node, name: 'deploy', value: deploy });
};
const createPosts = require('./gatsby/createPosts');
const createPages = require('./gatsby/createPages');
const createCategories = require('./gatsby/createCategories');
exports.createPages = async ({ actions, graphql }) => {
await createPosts({ actions, graphql });
await createPages({ actions, graphql });
await createCategories({ actions, graphql });
}