-
Notifications
You must be signed in to change notification settings - Fork 1
/
gatsby-node.js
59 lines (55 loc) · 1.66 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
58
59
const path = require("path");
// creates a page for each project added
exports.createPages = async ({graphql, actions}) => {
const { createPage } = actions
const projectTemplate = path.resolve(`src/templates/project.js`)
const pages = await graphql(`
query ProjectQuery {
allMarkdownRemark(filter: {fileAbsolutePath: {regex: "/projects/"}}) {
nodes {
frontmatter {
alt
description
image {
childImageSharp {
gatsbyImageData (
placeholder: BLURRED
formats: [AUTO, WEBP, AVIF]
)
}
}
link
slug
tags
title
repo
}
}
}
}
`)
// adds context to specified items so they can be used in the page template
let projects = pages.data.allMarkdownRemark.nodes;
projects.map(({frontmatter}) => {
const title = frontmatter.title
const image = frontmatter.image.childImageSharp.gatsbyImageData
const url = frontmatter.slug
const description = frontmatter.description
const tags = frontmatter.tags
const link = frontmatter.link
const repo = frontmatter.repo
createPage({
path: `/projects/${url}`,
component: projectTemplate,
context: {
title: title,
image: image,
url: url,
description: description,
tags: tags,
link: link,
repo: repo
}
})
})
}