1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-12-22 17:23:22 +01:00
portfolio/gatsby-node.js

63 lines
1.4 KiB
JavaScript
Raw Normal View History

2018-04-07 14:18:06 +02:00
const path = require('path')
2018-04-06 17:24:35 +02:00
2018-04-07 14:18:06 +02:00
exports.createPages = ({ boundActionCreators, graphql }) => {
const { createPage } = boundActionCreators
return new Promise((resolve, reject) => {
2018-04-08 22:49:58 +02:00
const template = path.resolve('src/components/organisms/Project.js')
2018-04-07 14:18:06 +02:00
2018-04-09 21:01:05 +02:00
resolve(graphql(`
2018-04-07 14:18:06 +02:00
{
allProjectsJson {
edges {
node {
title
slug
img
img_more
links {
Link
GitHub
Info
2018-04-09 21:01:05 +02:00
Dribbble
2018-04-07 14:18:06 +02:00
}
description
techstack
}
}
}
}
`).then(result => {
if (result.errors) {
reject(result.errors)
}
result.data.allProjectsJson.edges.forEach(({ node }) => {
const slug = node.slug
2018-04-08 22:49:58 +02:00
const title = node.title
const img = node.img
const img_more = node.img_more
const description = node.description
const links = node.links
const techstack = node.techstack
2018-04-07 14:18:06 +02:00
createPage({
path: slug,
component: template,
2018-04-08 22:49:58 +02:00
context: {
title,
slug,
img,
img_more,
description,
techstack,
2018-04-09 21:01:05 +02:00
links,
},
2018-04-07 14:18:06 +02:00
})
})
resolve()
}))
})
}