-
Notifications
You must be signed in to change notification settings - Fork 145
/
gatsby-node.js
66 lines (59 loc) · 1.34 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
require = require("esm")(module)
process.env.ELECT_LIVE_SHA = require("child_process")
.execSync("git rev-parse HEAD")
.toString()
.trim()
const fs = require("fs")
const path = require("path")
const {
provinces,
zones,
parties,
partyPath,
zonePath,
filters,
filterPath,
} = require("./src/models/information")
exports.createPages = async ({ actions }) => {
const { createPage } = actions
for (const party of parties) {
createPage({
path: partyPath(party),
component: path.resolve(`src/pages/party.js`),
context: {
partyId: party.id,
},
})
}
for (const province of provinces) {
for (const zone of zones.filter(z => z.provinceId === province.id)) {
createPage({
path: zonePath(zone),
component: path.resolve(`src/pages/index.js`),
context: {
zoneView: {
provinceId: province.id,
zoneNo: zone.no,
},
},
})
}
}
for (const filterName of Object.keys(filters)) {
createPage({
path: filterPath(filterName),
component: path.resolve(`src/pages/index.js`),
context: {
filterName: filterName,
},
})
}
}
exports.onPostBuild = async () => {
fs.writeFileSync(
"public/version.info.json",
JSON.stringify({
version: require("./package").version,
})
)
}