generated from jaronheard/civic-gatsby-starter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgatsby-node.js
112 lines (109 loc) · 2.85 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
/**
* Implement Gatsby's Node APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/node-apis/
*/
const path = require("path");
exports.createPages = async ({ graphql, actions, reporter }) => {
const { createPage, createRedirect } = actions;
createRedirect({
fromPath: "/project-form",
toPath: "https://form.jotform.com/200788029904056",
force: true
});
createRedirect({
fromPath: "/impact-form",
toPath: "https://form.jotform.com/200788029904056",
force: true
});
createRedirect({
fromPath: "/contributor-apply",
toPath: "https://form.jotform.com/200786890019057",
force: true
});
const result = await graphql(`
query {
allContentfulPost {
edges {
node {
slug
title
content {
json
}
authors {
name
email
}
createdAt(formatString: "MMMM DD, YYYY")
updatedAt(formatString: "MMMM DD, YYYY")
buttonText
buttonLocalLink
buttonExternalLink
}
}
}
allContentfulChallenge {
edges {
node {
slug
title
description {
json
}
tags
date
time
summary {
json
}
outcomes
applicants
link
completed
createdAt(formatString: "MMMM DD, YYYY")
updatedAt(formatString: "MMMM DD, YYYY")
}
}
}
}
`);
if (result.errors) {
reporter.panicOnBuild('🚨 ERROR: Loading "createPages" query');
}
// Create blog post pages.
const posts = result.data.allContentfulPost.edges;
// you'll call `createPage` for each result
posts.forEach(({ node }) => {
createPage({
// This is the slug you created before
// (or `node.frontmatter.slug`)
path: `/posts/${node.slug}`,
// This component will wrap our MDX content
component: path.resolve(`./src/components/PostTemplate.js`),
// You can use the values in this context in
// our page layout component
context: {
post: node
}
});
});
// Create focus session pages.
const sessions = result.data.allContentfulChallenge.edges;
// you'll call `createPage` for each result
sessions.forEach(({ node }) => {
createPage({
// This is the slug you created before
// (or `node.frontmatter.slug`)
path: `/sessions/${node.slug}`,
// This component will wrap our MDX content
component: path.resolve(`./src/components/ChallengeTemplate.js`),
// You can use the values in this context in
// our page layout component
context: {
challenge: node
}
});
});
};
// You can delete this file if you're not using it