-
Notifications
You must be signed in to change notification settings - Fork 1
/
gatsby-node.js
34 lines (29 loc) · 961 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
/**
* Implement Gatsby's Node APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/node-apis/
*/
// You can delete this file if you're not using it
const axios = require('axios')
exports.createPages = async ({ actions: { createPage } }) => {
const { data } = await axios.get(process.env.API_ENDPOINT)
// Create a page that lists all submissions.
createPage({
path: `/`,
component: require.resolve("./src/templates/pages-template.js"),
context: { pages: data.data.submissions },
})
// Create a page for each submission.
data.data.submissions.forEach(page => {
createPage({
path: `/job/${page.url}/`,
component: require.resolve("./src/templates/page-template.js"),
context: { page },
})
createPage({
path: `/job/${page.url}/apply`,
component: require.resolve("./src/templates/apply-template.js"),
context: { page },
})
})
}