-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgatsby-node.js
More file actions
49 lines (47 loc) · 1.1 KB
/
gatsby-node.js
File metadata and controls
49 lines (47 loc) · 1.1 KB
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
const path = require(`path`);
exports.createPages = async ({ graphql, actions }) => {
const { createPage } = actions;
// GET THE SINGLE PAGE VIEWERS:
const tourPageTemp = path.resolve(
'./src/templates/tour-page-template/tour.template.comp.jsx'
);
const blogPageTemp = path.resolve(
'./src/templates/blog-page-template/blog.template.comp.jsx'
);
const { data } = await graphql(`
query {
allTours: allContentfulEarthSlowTours {
edges {
node {
slug
}
}
}
allBlogs: allContentfulEarthSlowBogs {
edges {
node {
slug
}
}
}
}
`);
// SINGLE TOUR:
data.allTours.edges.forEach(({ node }) => {
const slug = node.slug.trim();
createPage({
path: `tours/${slug}`,
component: tourPageTemp,
context: { slug: slug },
});
});
// SINGLE BLOG OR POST:
data.allBlogs.edges.forEach(({ node }) => {
const slug = node.slug.trim();
createPage({
path: `blogs/${slug}`,
component: blogPageTemp,
context: { slug: slug },
});
});
};