-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-node.js
33 lines (32 loc) · 961 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
// uses require syntax not import
const path = require('path');
exports.createPages = ({graphql, actions}) => {
const {createPage} = actions; // same as actions.createPage
return new Promise((resolve, reject) => {
graphql (`
{
allMarkdownRemark {
edges {
node {
frontmatter{
title
slug
}
}
}
}
}
`).then(results => {
results.data.allMarkdownRemark.edges.forEach(({node}) => {
createPage({
path: `/posts${node.frontmatter.slug}`,
component: path.resolve('./src/components/postLayout.js'),
context: {
slug: node.frontmatter.slug,
}
});
})
resolve();
})
});
}