From e621a761e51b931d96494744630d1219cb0c16e4 Mon Sep 17 00:00:00 2001 From: Brandon Fancher Date: Sun, 30 Jun 2019 11:25:14 -0400 Subject: [PATCH] fix: support previews in other than defaultLang --- .../gatsby-source-prismic-graphql/src/gatsby-node.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/gatsby-source-prismic-graphql/src/gatsby-node.ts b/packages/gatsby-source-prismic-graphql/src/gatsby-node.ts index fbf208c74..0f489cb77 100755 --- a/packages/gatsby-source-prismic-graphql/src/gatsby-node.ts +++ b/packages/gatsby-source-prismic-graphql/src/gatsby-node.ts @@ -45,17 +45,13 @@ function createGeneralPreviewPage(createPage: Function, options: PluginOptions): }); } -function createDocumentPreviewPage(createPage: Function, options: PluginOptions, page: Page): void { +function createDocumentPreviewPage(createPage: Function, page: Page, lang?: string): void { + const rootQuery = getRootQuery(page.component); createPage({ path: page.path, matchPath: process.env.NODE_ENV === 'production' ? undefined : page.match, component: page.component, - context: { - rootQuery: getRootQuery(page.component), - id: '', - uid: '', - lang: options.defaultLang, - }, + context: { rootQuery, id: '', uid: '', lang }, }); } @@ -186,7 +182,7 @@ exports.createPages = async ({ graphql, actions: { createPage } }: any, options: const newEndCursor = response.pageInfo.endCursor; await createPagesForType(page, lang, newEndCursor, documents); } else { - createDocumentPreviewPage(createPage, options, page); + createDocumentPreviewPage(createPage, page, lang); createDocumentPages(createPage, documents, options, page); } }