1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-06-29 00:57:41 +02:00
portfolio/gatsby-node.js

81 lines
1.7 KiB
JavaScript

const path = require('path')
// https://github.com/saschajullmann/gatsby-starter-gatsbythemes/blob/master/gatsby-node.js
exports.modifyWebpackConfig = ({ config, stage }) => {
switch (stage) {
case 'develop':
config.preLoader('eslint-loader', {
test: /\.(js|jsx)$/,
exclude: /node_modules/,
})
break
}
return config
}
exports.createPages = ({ boundActionCreators, graphql }) => {
const { createPage } = boundActionCreators
return new Promise((resolve, reject) => {
const template = path.resolve('src/templates/Project.jsx')
resolve(graphql(`
{
allProjectsJson {
edges {
node {
title
slug
description
img
img_more
techstack
links {
title
url
}
}
previous {
title
slug
img
}
next {
title
slug
img
}
}
}
}
`).then(result => {
if (result.errors) {
reject(result.errors)
}
result.data.allProjectsJson.edges.forEach(
({ node, previous, next }) => {
const slug = node.slug
const img = node.img
const img_more = node.img_more
createPage({
path: slug,
component: template,
context: {
slug,
img,
img_more,
previous,
next,
},
})
}
)
resolve()
}))
})
}