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

78 lines
1.8 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-11 13:46:55 +02:00
Download
2018-04-07 14:18:06 +02:00
}
description
techstack
}
2018-04-15 21:08:59 +02:00
previous {
title
slug
img
}
next {
title
slug
img
}
2018-04-07 14:18:06 +02:00
}
}
}
`).then(result => {
if (result.errors) {
reject(result.errors)
}
2018-04-15 21:08:59 +02:00
result.data.allProjectsJson.edges.forEach(
({ node, previous, next }) => {
const slug = node.slug
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
2018-04-15 21:08:59 +02:00
createPage({
path: slug,
component: template,
context: {
title,
slug,
img,
img_more,
description,
techstack,
links,
previous,
next,
},
})
}
)
2018-04-07 14:18:06 +02:00
resolve()
}))
})
}