forked from Hacker0x01/docs.hackerone.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-node.js
54 lines (49 loc) · 1.57 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
48
49
50
51
52
53
54
const path = require("path");
exports.createPages = ({ graphql, actions }) => {
const { createPage } = actions;
const programsTemplate = path.resolve('./src/templates/programs.js');
const hackersTemplate = path.resolve('./src/templates/hackers.js');
const changelogTemplate = path.resolve('./src/templates/changelog.js');
const glossaryTemplate = path.resolve('./src/templates/glossary.js');
const accessibilityTemplate = path.resolve('./src/templates/accessibility.js');
return graphql(`
{
allMarkdownRemark(
sort: { order: ASC, fields: [frontmatter___title] }
limit: 1000
) {
edges {
node {
html
frontmatter {
title
path
}
}
}
}
}
`).then(result => {
if (result.errors) {
return Promise.reject(result.errors);
}
result.data.allMarkdownRemark.edges.forEach(({ node }) => {
let template;
if (node.frontmatter.path.includes("/programs")) {
template = programsTemplate;
} else if (node.frontmatter.path.includes("/hackers")) {
template = hackersTemplate;
} else if (node.frontmatter.path.includes("/changelog")) {
template = changelogTemplate;
} else if (node.frontmatter.path.includes("/glossary")) {
template = glossaryTemplate;
} else if (node.frontmatter.path.includes("/accessibility")) {
template = accessibilityTemplate;
}
createPage({
path: node.frontmatter.path,
component: template,
});
});
});
};