-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgatsby-node.js
57 lines (42 loc) · 1.63 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
52
53
54
55
const path = require(`path`)
/**
* exports.createPages is a built-in Gatsby Node API.
* It's purpose is to allow you to create pages for your site! 💡
*
* See https://www.gatsbyjs.com/docs/node-apis/#createPages for more info.
*/
exports.createPages = async gatsbyUtilities => {
const alphabet = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];
if (!alphabet.length) {
return
}
await createIndividualPages({ alphabet, gatsbyUtilities })
}
/**
* This function creates all the individual blog pages in this site
*/
const createIndividualPages = async ({ alphabet, gatsbyUtilities }) => {
let template="./src/templates/page.js"
await Promise.all(
alphabet.map( ( letter ) => {
// createPage is an action passed to createPages
// See https://www.gatsbyjs.com/docs/actions#createPage for more info
gatsbyUtilities.actions.createPage({
// Use the WordPress uri as the Gatsby page path
// This is a good idea so that internal links and menus work 👍
path: "digital-product-glossary/terms/"+letter,
// use the blog post template as the page component
component: path.resolve(template),
// `context` is available in the template as a prop and
// as a variable in GraphQL.
context: {
// we need to add the post id here
// so our blog post template knows which blog post
// the current page is (when you open it in a browser)
letter: letter
},
})
}
)
)
}