-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgatsby-node.js
66 lines (60 loc) · 1.5 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
56
57
58
59
60
61
62
63
64
65
66
const fs = require('fs')
const path = require('path')
const yaml = require('js-yaml')
const { paramCase, pascalCase } = require('change-case')
//
const stackedPageTemplate = require.resolve('./src/templates/stacked-page.js')
exports.createPages = async ({ actions, graphql, reporter }) => {
const { createPage } = actions
const results = await graphql(`{
allPagesYaml {
nodes {
path
}
}
}`)
// create a page from each the page yaml files
results.data.allPagesYaml.nodes.forEach(node => {
// create page and pass section content in context
createPage({
path: node.path,
component: stackedPageTemplate,
context: {
pagePath: node.path,
},
})
})
}
exports.createSchemaCustomization = ({ actions }) => {
const { createTypes} = actions
const typeDefs = `
type Hero {
id: ID!
background_image: File! @link(by: "relativePath")
blurb: String!
title: String!
}
type PagesYaml implements Node {
title: String!
description: String!
path: String!
hero: Hero
sections: [String!]!
}
type Student {
student_name: String!
student_photo: File! @link(by: "relativePath")
project_description: String!
}
type CtaButton {
title: String!
background_image: File! @link(by: "relativePath")
}
type SectionsYaml implements Node {
students: [Student!]
students_cta: CtaButton!
staff_cta: CtaButton!
}
`
createTypes(typeDefs)
}