This repository has been archived by the owner on Feb 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gatsby-node.js
85 lines (85 loc) · 2.42 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
const path = require("path")
exports.createPages = ({ graphql, boundActionCreators }) => {
const { createPage } = boundActionCreators
return new Promise((resolve, reject) => {
const BlogPostTemplateDe = path.resolve("src/templates/blog-posts.de.js")
const BlogPostTemplateEn = path.resolve("src/templates/blog-posts.en-US.js")
resolve(
graphql(`
{
allContentfulBlogPost {
edges {
node {
slug
node_locale
}
}
}
}
`).then(result => {
if (result.errors) {
reject(result.errors)
}
result.data.allContentfulBlogPost.edges.forEach(edge => {
edge.node.node_locale === "de"
? createPage({
path: "/" + edge.node.slug,
component: BlogPostTemplateDe,
context: {
slug: edge.node.slug,
node_locale: edge.node.node_locale,
},
})
: createPage({
path: "/en-US/" + edge.node.slug,
component: BlogPostTemplateEn,
context: {
slug: edge.node.slug,
node_locale: edge.node.node_locale,
},
})
})
return
})
)
}).then(result => {
const serviceTemplateDe = path.resolve("src/templates/services.de.js")
const serviceTemplateEn = path.resolve("src/templates/services.en-US.js")
graphql(`
{
allContentfulServices {
edges {
node {
slug
node_locale
}
}
}
}
`).then(result => {
if (result.errors) {
reject(result.errors)
}
result.data.allContentfulServices.edges.forEach(edge => {
edge.node.node_locale === "de"
? createPage({
path: "/services/" + edge.node.slug,
component: serviceTemplateDe,
context: {
slug: edge.node.slug,
node_locale: edge.node.node_locale,
},
})
: createPage({
path: "/en-US/services/" + edge.node.slug,
component: serviceTemplateEn,
context: {
slug: edge.node.slug,
node_locale: edge.node.node_locale,
},
})
})
return
})
})
}