-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathgatsby-node.js
More file actions
75 lines (72 loc) · 1.63 KB
/
Copy pathgatsby-node.js
File metadata and controls
75 lines (72 loc) · 1.63 KB
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
const path = require(`path`);
// Log out information after a build is done
exports.onPostBuild = ({ reporter }) => {
reporter.info(`Your Gatsby site has been built!`);
};
// Create blog pages dynamically
exports.createPages = async ({ graphql, actions }) => {
const { createPage } = actions;
// Gallery
const result = await graphql(galleryQuery);
result.data.allGalleryJson.edges.forEach((edge) => {
createPage({
path: `/gallery/${edge.node.date} ${edge.node.name}`,
component: path.resolve("src/templates/gallery.js"),
context: edge.node,
});
});
const memberEdges = result.data.allMemberJson.edges;
for (let i = 0; i < memberEdges.length; i++) {
const edge = memberEdges[i];
const prevUrl = i === 0 ? null : memberEdges[i - 1].node.url;
const nextUrl =
i === memberEdges.length - 1 ? null : memberEdges[i + 1].node.url;
createPage({
path: `/members/${edge.node.url}`,
component: path.resolve("src/templates/member_page.js"),
context: {
node: edge.node,
prevUrl: prevUrl,
nextUrl: nextUrl,
},
});
}
};
const galleryQuery = `
query {
allGalleryJson(sort: { date: DESC }) {
edges {
node {
id
name
photos
date
}
}
}
allMemberJson(sort: { endDate: ASC }) {
edges {
node {
id
name
url
description
image
startDate
endDate
members {
description
image
name
position
links {
icon_type
text
url
}
}
}
}
}
}
`;