-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-node.js
43 lines (39 loc) · 958 Bytes
/
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
const OTHER_INTROS = require('./src/contants/intros.json');
// eslint-disable-next-line import/prefer-default-export
exports.createPages = async ({ actions, graphql }) => {
const result = await graphql(`
{
allSanityPost {
edges {
node {
slug {
current
}
}
}
}
}
`);
if (result.errors) {
throw result.errors;
}
const posts = result.data.allSanityPost.edges.map(({ node }) => node);
posts.forEach((post) => {
actions.createPage({
path: `/blog/${post.slug.current}`,
component: require.resolve('./src/templates/Post.js'),
context: {
slug: post.slug.current,
},
});
});
OTHER_INTROS.forEach((intro) => {
actions.createPage({
path: `/intro/${intro.slug}`,
component: require.resolve('./src/templates/PurchaseIntro.js'),
context: {
slug: intro.slug,
},
});
});
};