-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-node.js
57 lines (54 loc) · 1.28 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
55
56
57
const redirects = require("./redirects")
exports.createPages = async ({ graphql, actions, reporter }) => {
const { createPage, createRedirect } = actions
redirects.forEach(({ from, to, ...config }) =>
createRedirect({
fromPath: from,
toPath: to,
isPermanent: true,
redirectInBrowser: true,
...config,
})
)
let folders = {
solutions: {
templateName: "solutions-layout.js",
frontmatter: "title link",
},
projects: { templateName: "project-layout.js", frontmatter: "title link" },
}
Object.keys(folders).map(async folder => {
let result = await graphql(`
{
x: allFile(
filter: {
sourceInstanceName: {eq: "${folder}"},
ext: {in: [".md",".mdx"]
}
}) {
nodes {
id
childMdx {
frontmatter {
${folders[folder].frontmatter}
}
}
}
}
}
`)
//create each individual blog post
result.data.x.nodes.forEach(node => {
const { link } = node.childMdx.frontmatter
createPage({
path: `${link}/`,
component: require.resolve(
`./src/templates/${folders[folder].templateName}`
),
context: {
link,
},
})
})
})
}