birkir / gatsby-source-prismic-graphql

Gatsby source plugin for Prismic GraphQL
MIT License
137 stars 75 forks source link

[bug] Node crashing when using onCreatePage #220

Open mrseanbaines opened 4 years ago

mrseanbaines commented 4 years ago

Description

When implementing Gatsby's onCreatePage function to dynamically generate localized versions of pages, with gatsby-source-prismic-graphql Gatsby appears to get into an infinite loop on the createPagesStatefully step, thus preventing page generation and startup.

I realise this plugin has options to dynamically create pages without the need for utilizing Gatsby's onCreatePage, however, I would like more granular control over this (e.g. using country codes instead of language codes), also I am migrating from Contentful and still have pages that require this existing system for creating localized pages.

const countries = ["gb", "de", "es"]

exports.onCreatePage = async ({ page, actions }) => {
  actions.deletePage(page)

  countries.forEach(country => {
    actions.createPage({
      ...page,
      path: `/${country}${page.path}`,
    })
  })
}

Minimal reproduction: https://github.com/mrseanbaines/gatsby-prismic-blog

Related issues

164

cbasJS commented 4 years ago

Same issue here. Someone else?