-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-node.js
110 lines (100 loc) · 2.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
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
exports.createPages = ({ actions, graphql }) => {
const { createPage } = actions
// Start wiki-index
const wikiIndexTemplate = require.resolve(`./src/templates/wiki-index.jsx`)
const wikiIndex = graphql(`
{
allMarkdownRemark(
filter: {frontmatter:{ type: {eq: "wiki-index"}}}
) {
edges {
node {
id
frontmatter {
slug
}
}
}
}
}
`).then(result => {
if (result.errors) {
return Promise.reject(result.errors)
}
return result.data.allMarkdownRemark.edges.forEach(({ node }) => {
return createPage({
path: node.frontmatter.slug,
component: wikiIndexTemplate,
context: {
slug: node.frontmatter.slug,
id: node.id,
},
})
})
});
// Start wiki-entry
const wikiEntryTemplate = require.resolve(`./src/templates/wiki-entry.jsx`)
const wikiEntry = graphql(`
{
allMarkdownRemark(
filter: {frontmatter:{ type: {eq: "wiki-entry"}}}
) {
edges {
node {
id
frontmatter {
slug
}
}
}
}
}
`).then(result => {
if (result.errors) {
return Promise.reject(result.errors)
}
return result.data.allMarkdownRemark.edges.forEach(({ node }) => {
return createPage({
path: `wiki/${node.frontmatter.slug}`,
component: wikiEntryTemplate,
context: {
id: node.id,
},
})
})
});
// Start blog-entry
// Start wiki-entry
const blogEntryTemplate = require.resolve(`./src/templates/blog-entry.jsx`)
const blogEntry = graphql(`
{
allMarkdownRemark(
filter: {frontmatter:{ type: {eq: "blog-entry"}}}
) {
edges {
node {
id
frontmatter {
slug
}
}
}
}
}
`).then(result => {
if (result.errors) {
return Promise.reject(result.errors)
}
return result.data.allMarkdownRemark.edges.forEach(({ node }) => {
return createPage({
path: `blog/${node.frontmatter.slug}`,
component: blogEntryTemplate,
context: {
id: node.id,
},
})
})
});
// Combining all
return Promise.all([wikiEntry, wikiIndex, blogEntry]);
}