Skip to content
Permalink
Browse files
Create pages from Prismic posts
  • Loading branch information
RyanWarner committed Jun 12, 2020
1 parent f6def75 commit 23a2694c590535ba866702d6d6d742ff4d782519
Showing 2 changed files with 46 additions and 6 deletions.
@@ -1,7 +1,39 @@
/**
* Implement Gatsby's Node APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/node-apis/
*/
const path = require('path')

// You can delete this file if you're not using it
exports.createPages = async ({ graphql, actions }) => {
const { createPage } = actions

// Query all Pages with their IDs and template data.
const pages = await graphql(`
{
allPrismicPost {
edges {
node {
data {
title {
text
}
}
id
first_publication_date
uid
}
}
}
}
`)

const postTemplate = path.resolve('./src/components/PostTemplate/PostTemplate.js')

// Create pages for each Post in Prismic.
pages.data.allPrismicPost.edges.forEach((edge) => {
console.log('edge.node.uid', edge.node.uid)
createPage({
path: `${edge.node.uid}`,
component: postTemplate,
context: {
id: edge.node.id,
},
})
})
}
@@ -0,0 +1,8 @@
import React from "react"

const PostLayout = props => {
console.log(props)
return <div>hello</div>
}

export default PostLayout

0 comments on commit 23a2694

Please sign in to comment.