-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgatsby-node.js
96 lines (89 loc) · 2.67 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
const Promise = require('bluebird')
const path = require('path')
exports.createPages = ({ graphql, actions }) => {
const { createPage } = actions
return new Promise((resolve, reject) => {
const blogPost = path.resolve('./src/templates/blog-post.js')
const quickTip = path.resolve('./src/templates/quick-tip.js')
const fpvNews = path.resolve('./src/templates/fpv-news.js')
resolve(
graphql(
`
{
posts: allMarkdownRemark(
sort: { order: DESC, fields: [frontmatter___date] }
filter: {
frontmatter: { draft: { ne: true } }
fileAbsolutePath: { regex: "/content/posts/" }
}
) {
edges {
node {
id
frontmatter {
path
}
}
}
}
quickTips: allMarkdownRemark(
sort: { order: DESC, fields: [frontmatter___date] }
filter: { fileAbsolutePath: { regex: "/content/quick-tips/" } }
) {
edges {
node {
id
frontmatter {
path
}
}
}
}
allFpvNews: allMarkdownRemark(
sort: { order: DESC, fields: [frontmatter___date] }
filter: { fileAbsolutePath: { regex: "/content/fpv-news/" } }
) {
edges {
node {
id
frontmatter {
path
}
}
}
}
}
`
).then(result => {
if (result.errors) {
console.log(result.errors)
reject(result.errors)
}
// Create blog posts pages.
result.data.posts.edges.forEach(({ node }) => {
createPage({
path: node.frontmatter.path,
component: blogPost,
context: {}, // additional data can be passed via context
})
})
// Create quick tips pages.
result.data.quickTips.edges.forEach(({ node }) => {
createPage({
path: node.frontmatter.path,
component: quickTip,
context: {}, // additional data can be passed via context
})
})
// Create newsletter pages.
result.data.allFpvNews.edges.forEach(({ node }) => {
createPage({
path: node.frontmatter.path,
component: fpvNews,
context: {}, // additional data can be passed via context
})
})
})
)
})
}