2018-04-07 14:18:06 +02:00
|
|
|
const path = require('path')
|
2018-04-06 17:24:35 +02:00
|
|
|
|
2018-05-04 21:48:09 +02:00
|
|
|
// https://github.com/gatsbyjs/gatsby/issues/2288#issuecomment-334467821
|
|
|
|
exports.modifyWebpackConfig = ({ config, stage }) => {
|
|
|
|
if (stage === 'build-html') {
|
|
|
|
config.loader('null', {
|
|
|
|
test: /intersection-observer/,
|
|
|
|
loader: 'null-loader',
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2018-05-05 00:17:26 +02:00
|
|
|
allProjectsYaml {
|
2018-04-07 14:18:06 +02:00
|
|
|
edges {
|
|
|
|
node {
|
|
|
|
slug
|
|
|
|
}
|
2018-04-15 21:08:59 +02:00
|
|
|
previous {
|
|
|
|
title
|
|
|
|
slug
|
2018-05-04 14:00:21 +02:00
|
|
|
img {
|
|
|
|
id
|
|
|
|
childImageSharp {
|
2018-05-05 20:59:24 +02:00
|
|
|
sizes(maxWidth: 500, quality: 80) {
|
2018-05-04 14:00:21 +02:00
|
|
|
aspectRatio
|
|
|
|
src
|
|
|
|
srcSet
|
|
|
|
srcWebp
|
|
|
|
srcSetWebp
|
|
|
|
sizes
|
|
|
|
originalImg
|
|
|
|
originalName
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-04-15 21:08:59 +02:00
|
|
|
}
|
|
|
|
next {
|
|
|
|
title
|
|
|
|
slug
|
2018-05-04 14:00:21 +02:00
|
|
|
img {
|
|
|
|
id
|
|
|
|
childImageSharp {
|
2018-05-05 20:59:24 +02:00
|
|
|
sizes(maxWidth: 500, quality: 80) {
|
2018-05-04 14:00:21 +02:00
|
|
|
aspectRatio
|
|
|
|
src
|
|
|
|
srcSet
|
|
|
|
srcWebp
|
|
|
|
srcSetWebp
|
|
|
|
sizes
|
|
|
|
originalImg
|
|
|
|
originalName
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-04-15 21:08:59 +02:00
|
|
|
}
|
2018-04-07 14:18:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`).then(result => {
|
|
|
|
if (result.errors) {
|
|
|
|
reject(result.errors)
|
|
|
|
}
|
|
|
|
|
2018-05-05 00:17:26 +02:00
|
|
|
result.data.allProjectsYaml.edges.forEach(
|
2018-04-30 01:18:54 +02:00
|
|
|
({ 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()
|
|
|
|
}))
|
|
|
|
})
|
|
|
|
}
|