Initial commit
This commit is contained in:
commit
5a3bf52ebb
86 changed files with 2639 additions and 0 deletions
51
web/gatsby-node.js
Normal file
51
web/gatsby-node.js
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
const {isFuture} = require('date-fns')
|
||||
/**
|
||||
* Implement Gatsby's Node APIs in this file.
|
||||
*
|
||||
* See: https://www.gatsbyjs.org/docs/node-apis/
|
||||
*/
|
||||
|
||||
async function createProjectPages (graphql, actions, reporter) {
|
||||
const {createPage, createPageDependency} = actions
|
||||
const result = await graphql(`
|
||||
{
|
||||
allSanityProject(filter: {slug: {current: {ne: null}}, publishedAt: {ne: null}}) {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
publishedAt
|
||||
slug {
|
||||
current
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`)
|
||||
|
||||
if (result.errors) throw result.errors
|
||||
|
||||
const projectEdges = (result.data.allSanityProject || {}).edges || []
|
||||
|
||||
projectEdges
|
||||
.filter(edge => !isFuture(edge.node.publishedAt))
|
||||
.forEach(edge => {
|
||||
const id = edge.node.id
|
||||
const slug = edge.node.slug.current
|
||||
const path = `/project/${slug}/`
|
||||
|
||||
reporter.info(`Creating project page: ${path}`)
|
||||
|
||||
createPage({
|
||||
path,
|
||||
component: require.resolve('./src/templates/project.js'),
|
||||
context: {id}
|
||||
})
|
||||
|
||||
createPageDependency({path, nodeId: id})
|
||||
})
|
||||
}
|
||||
|
||||
exports.createPages = async ({graphql, actions, reporter}) => {
|
||||
await createProjectPages(graphql, actions, reporter)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue