-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-node.js
47 lines (45 loc) · 1.19 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
// The purpose of this file is to give control and what's being registered in Gatsby
const path = require('path');
//creating pages for only the projects (which are filtered based on the absolute path)
exports.createPages = ({
graphql,
actions
}) => {
const {
createPage
} = actions;
return new Promise((resolve) => {
graphql(`
{
allMarkdownRemark(filter: {fileAbsolutePath: {regex: "\/projects/"}}) {
edges {
node {
html
frontmatter {
title
URLpath
published
date
description
}
}
}
}
}
`).then(results => {
results.data.allMarkdownRemark.edges.forEach(({
node
}) => {
createPage({
path: `/projects${node.frontmatter.URLpath}`,
component: path.resolve('./src/components/ProjectLayout.jsx'),
context: {
URLpath: node.frontmatter.URLpath, //takes the path that is in the markdown and stores the file there
}
});
});
resolve();
});
});
};
// create new 'createPages things to form new queries