Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

gatsby creating pages from contentful

const path = require('path')

exports.createPages = ({graphql, boundActionCreators}) => {
  const {createPage} = boundActionCreators
  return new Promise((resolve, reject) => {
    const storeTemplate = path.resolve('src/templates/store.js')
    resolve(
      graphql(`
        {
          allContentfulStore (limit:100) {
            edges {
              node {
                id
                name
                slug
              }
            }
          }
        }
      `).then((result) => {
        if (result.errors) {
          reject(result.errors)
        }
        result.data.allContentfulStore.edges.forEach((edge) => {
          createPage ({
            path: edge.node.slug,
            component: storeTemplate,
            context: {
              slug: edge.node.slug
            }
          })
        })
        return
      })
    )
  })
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: sequelize body 
Javascript :: check a divide condition and print msg javascript 
Javascript :: create a link in react js to download xcelfile 
Javascript :: js get url static without path from strin 
Javascript :: javascript see if chrome is in dark mode 
Javascript :: aba translate js 
Javascript :: agregar año en javascript 
Javascript :: capturar el id de un elemento con jquery 
Javascript :: chromepicker react-color not working 
Javascript :: error check variable 
Javascript :: print from mongo console to file sample.json 
Javascript :: How to make move able triangle in canvas js 
Javascript :: how to sort a 2d array in javascript 
Javascript :: javascript select element with pointer 
Javascript :: regex reuse pattern 
Javascript :: finnhub 
Javascript :: replace with regex capture group 
Javascript :: threejs torus shape 
Javascript :: get all youtube playlist videos as json without api python 
Javascript :: sinon chaining method 
Javascript :: javascript accessing this in callback 
Javascript :: how to toglle button in viewjs 
Javascript :: correctly type checking objects in javascript 
Javascript :: 8.1.1. Declaring an Array¶ 
Javascript :: exemple de modal reactjs 
Javascript :: How to update Code Mirror data on modal show 
Javascript :: vue apollo refetch every x ms 
Javascript :: how to pass custom parameter onchage 
Javascript :: package json replace to dev dependencies 
Javascript :: window.getselection outside 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =