Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
fix: support previews in other than defaultLang
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonfancher committed Jul 12, 2019
1 parent bbe2aa5 commit e621a76
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions packages/gatsby-source-prismic-graphql/src/gatsby-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
});
}

Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit e621a76

Please sign in to comment.