diff --git a/gatsby-config.js b/gatsby-config.js index 541208cdd..0698e173c 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -48,7 +48,9 @@ module.exports = { file: `${__dirname}/src/data/related-pages.json`, engineKey: 'Ad9HfGjDw4GRkcmJjUut', pageLimit: 5, - getPath: ({ node }) => node.frontmatter.path, + getParams: ({ node }) => ({ + path: node.frontmatter.path, + }), filterNode: ({ node }) => node.internal.type === 'Mdx' && node.frontmatter.template === 'GuideTemplate', diff --git a/plugins/gatsby-source-swiftype/gatsby-node.js b/plugins/gatsby-source-swiftype/gatsby-node.js index 9d18bbaa7..1f9cfd965 100644 --- a/plugins/gatsby-source-swiftype/gatsby-node.js +++ b/plugins/gatsby-source-swiftype/gatsby-node.js @@ -21,7 +21,7 @@ exports.onPreBootstrap = ({ reporter }, pluginOptions) => { exports.onCreateNode = async ({ node, getNodesByType }, pluginOptions) => { const { filterNode = () => false, - getPath, + getParams, pageLimit, engineKey, } = pluginOptions; @@ -32,15 +32,23 @@ exports.onCreateNode = async ({ node, getNodesByType }, pluginOptions) => { const [{ siteMetadata }] = getNodesByType('Site'); const { siteUrl } = siteMetadata; - const pathname = getPath({ node }); + const { path: pathname, filters = {}, ...params } = getParams({ node }); + const { page: pageFilters = {} } = filters; const url = new URL(pathname, siteUrl); - const params = { + const allParams = { + ...params, engine_key: engineKey, per_page: pageLimit, filters: { + ...filters, page: { - url: [`!${appendTrailingSlash(url)}`, `!${stripTrailingSlash(url)}`], + ...pageFilters, + url: [ + `!${appendTrailingSlash(url)}`, + `!${stripTrailingSlash(url)}`, + ...(pageFilters.url || []), + ], }, }, };