-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgatsby-node.js
More file actions
57 lines (54 loc) · 1.29 KB
/
gatsby-node.js
File metadata and controls
57 lines (54 loc) · 1.29 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
50
51
52
53
54
55
56
57
// See: https://www.gatsbyjs.org/docs/node-apis/
const path = require('path');
// BLOG
exports.createPages = async function ({ graphql, actions }) {
const { createPage, createRedirect } = actions;
// SITE REDIRECTS
createRedirect({
fromPath: 'https://ashchristie.netlify.com',
toPath: 'https://www.ashco.io',
isPermanent: true,
});
await graphql(`
{
allContentfulPortfolioProject {
edges {
node {
slug
}
}
}
allContentfulBlogPost {
edges {
node {
slug
}
}
}
}
`).then((result) => {
// PORTFOLIO
result.data.allContentfulPortfolioProject.edges.forEach(({ node }) => {
createPage({
// can use this fnc to create pages outside of promises
path: `projects/${node.slug}`,
component: path.resolve(
'./src/components/Projects/ProjectsPageSelected.js'
),
context: {
slug: node.slug,
},
});
});
// BLOG
result.data.allContentfulBlogPost.edges.forEach(({ node }) => {
createPage({
path: `blog/${node.slug}`,
component: path.resolve('./src/components/Blog/BlogPage.js'),
context: {
slug: node.slug,
},
});
});
});
};