-
Notifications
You must be signed in to change notification settings - Fork 1
/
gatsby-node.js
134 lines (124 loc) · 2.78 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// The purpose of this file is to give control and what's being registered in Gatsby
const path = require('path');
plugins: [{
resolve: 'gatsby-plugin-react-css-modules',
options: {
// *.css files are included by default.
// To support another syntax (e.g. SCSS),
// add 'postcss-scss' to your project's devDependencies
// and add the following option here:
filetypes: {
'.scss': {
syntax: 'postcss-scss'
},
},
// Exclude global styles from the plugin using a RegExp:
exclude: '\/global\/',
},
}, ];
// creating speaker pages
exports.createPages = ({
graphql,
actions
}) => {
const {
createPage
} = actions;
//speaker template component
const speakerTemplate = path.resolve('./src/components/templates/SpeakerContentfulTemplate.jsx');
const eventTemplate = path.resolve('./src/components/templates/EventContentfulTemplate.jsx');
// query for gettting speakers
return graphql(`
{
speakers: allContentfulSpeakersLibrary {
totalCount
edges {
node {
slug
name
job
webpage
bio {
bio
}
headshot {
fluid {
src
}
}
}
}
}
events: allContentfulEventsLibrary {
totalCount
edges {
node {
slug
name
coverPhoto {
fluid(maxWidth: 400, maxHeight: 400) {
src
}
}
startTime
endTime
location
description {
description
}
eventRegistrationWebpage
eventScheduleItems {
name
startTime
endTime
description {
description
}
eventType
location
speakers {
name
slug
}
}
speaker {
job
slug
headshot {
fluid(maxWidth: 400, maxHeight: 400) {
src
}
}
}
}
}
}
}
`).then(result => {
if (result.errors) {
Promise.reject(result.errors);
}
// Create speakers page
const speakers = result.data.speakers.edges;
speakers.forEach((speaker) => {
createPage({
path: `/speakers/${speaker.node.slug}`,
component: speakerTemplate,
context: {
slug: speaker.node.slug,
},
});
});
// Create events page
const events = result.data.events.edges;
events.forEach((event) => {
createPage({
path: `/events/${event.node.slug}`,
component: eventTemplate,
context: {
slug: event.node.slug,
},
});
});
});
};