1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-07-01 06:01:48 +02:00
portfolio/gatsby-node.js

81 lines
1.7 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-27 21:19:19 +02:00
// 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
}
2018-04-07 14:18:06 +02:00
exports.createPages = ({ boundActionCreators, graphql }) => {
const { createPage } = boundActionCreators
return new Promise((resolve, reject) => {
2018-04-25 23:37:23 +02:00
const template = path.resolve('src/templates/Project.jsx')
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
2018-04-20 22:56:18 +02:00
description
2018-04-07 14:18:06 +02:00
img
img_more
2018-04-20 22:56:18 +02:00
techstack
2018-04-07 14:18:06 +02:00
links {
2018-04-20 22:56:18 +02:00
title
url
2018-04-07 14:18:06 +02:00
}
}
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-30 01:18:54 +02:00
result.data.allProjectsJson.edges.forEach(
({ node, previous, next }) => {
2018-04-15 21:08:59 +02:00
const slug = node.slug
2018-04-21 20:01:50 +02:00
const img = node.img
const img_more = node.img_more
2018-04-07 14:18:06 +02:00
2018-04-15 21:08:59 +02:00
createPage({
2018-04-22 18:56:31 +02:00
path: slug,
2018-04-15 21:08:59 +02:00
component: template,
context: {
slug,
2018-04-21 20:01:50 +02:00
img,
img_more,
2018-04-15 21:08:59 +02:00
previous,
next,
},
})
}
)
2018-04-07 14:18:06 +02:00
resolve()
}))
})
}