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-21 13:39:18 +02:00
|
|
|
const template = path.resolve('src/templates/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
|
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-21 13:39:18 +02:00
|
|
|
result.data.allProjectsJson.edges.forEach(({ node, previous, next }) => {
|
2018-04-15 21:08:59 +02:00
|
|
|
const slug = node.slug
|
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,
|
|
|
|
previous,
|
|
|
|
next,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
)
|
2018-04-07 14:18:06 +02:00
|
|
|
|
|
|
|
resolve()
|
|
|
|
}))
|
|
|
|
})
|
|
|
|
}
|
2018-04-21 02:03:45 +02:00
|
|
|
|
2018-04-21 13:39:18 +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-21 02:03:45 +02:00
|
|
|
// https://github.com/gatsbyjs/gatsby/issues/2285#issuecomment-333343938
|
|
|
|
exports.modifyWebpackConfig = ({ config, stage }) => {
|
|
|
|
if (stage === 'build-html') {
|
|
|
|
config.loader('null', {
|
|
|
|
test: /webfontloader/,
|
|
|
|
loader: 'null-loader',
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|