From 674e1c745a2ceb907e76b71a0e21c37f5600f82d Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Wed, 12 Aug 2020 23:04:00 -0700 Subject: [PATCH] feat: filter out redirects and already defined urls for a page --- gatsby-config.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/gatsby-config.js b/gatsby-config.js index 10b9b79f7..f74dc1381 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -53,7 +53,16 @@ module.exports = { pageLimit: 5, getPath: ({ node }) => node.frontmatter.path, getParams: ({ node }) => { - const { tags, title } = node.frontmatter; + const { + tags, + title, + redirects = [], + resources = [], + } = node.frontmatter; + + const filteredUrls = resources + .map((resource) => resource.url) + .concat(redirects); return { q: tags ? tags.map(quote).join(' OR ') : title, @@ -62,6 +71,11 @@ module.exports = { }, filters: { page: { + url: filteredUrls.map((url) => + url.startsWith('/') + ? `!https://developer.newrelic.com${url}` + : `!${url}` + ), document_type: [ '!views_page_menu', '!term_page_api_menu',