forked from heyheyzay/womenwhodesign
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-node.js
51 lines (48 loc) · 1.17 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
const path = require(`path`);
const _ = require("lodash");
exports.onCreateNode = ({ node, actions }) => {
const { createNodeField } = actions;
if (node.internal.type === `Seeker`) {
const slug = `jobs/${node.job.id.slice(0, 5)}-${_.kebabCase(
node.job.company.name
)}-${_.kebabCase(node.job.job_title)}`;
createNodeField({
node,
name: `slug`,
value: slug
});
}
};
exports.createPages = ({ graphql, actions }) => {
const { createPage } = actions;
return new Promise(resolve => {
graphql(`
{
allSeeker {
edges {
node {
fields {
slug
}
}
}
}
}
`).then(result => {
if (result.data) {
result.data.allSeeker.edges.forEach(({ node }) => {
createPage({
path: node.fields.slug,
component: path.resolve(`./src/templates/job-post.js`),
context: {
// Data passed to context is available
// in page queries as GraphQL variables.
slug: node.fields.slug
}
});
});
}
resolve();
});
});
};