Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const path = require(`path`)
- exports.createPages = async ({ graphql, actions }) => {
- const { createPage } = actions;
- const blogPostTemplate = path.resolve(`src/components/PostLayout.js`);
- return graphql(`
- query {
- allPost {
- edges {
- node {
- id
- }
- }
- }
- }
- `).then((result) => {
- if(result.errors) {
- throw result.errors;
- }
- // console.log(JSON.stringify(result, null, 4))
- result.data.allPost.edges.map(post => {
- createPage({
- path: `/post/${post.node.id}`,
- component: blogPostTemplate,
- context: {
- slug: {
- eq: post.node.id
- }
- }
- })
- })
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement