-
Notifications
You must be signed in to change notification settings - Fork 1
/
gatsby-node.js
37 lines (31 loc) · 1.04 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
const slugify = require('slugify')
const { createFilePath, createFileNode } = require(`gatsby-source-filesystem`)
const path = require('path')
const createJobPostPages = require('./gatsby/create-jobpost-pages')
const createOfficePages = require('./gatsby/create-office-pages')
const createDepartmentPages = require('./gatsby/create-department-pages')
exports.onCreateNode = ({ node, getNode, actions }) => {
const { createNodeField } = actions
// job nodes have a 'title' property, office and department nodes have a 'name' property
const slugString = node.title || node.name
const slugOptions = {
replacement: '-',
remove: RegExp(/[*+~.()'"!?:@]/g),
lower: true,
strict: true
}
if (slugString) {
createNodeField({
node,
name: `slug`,
value: `${slugify(slugString, slugOptions)}`,
})
}
}
exports.createPages = ({ actions, graphql }) => {
return Promise.all([
createJobPostPages({ actions, graphql }),
createOfficePages({ actions, graphql }),
createDepartmentPages({ actions, graphql })
])
}