Skip to content

Commit

Permalink
feat: filter out redirects and already defined urls for a page
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Aug 13, 2020
1 parent 04b1828 commit 674e1c7
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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',
Expand Down

0 comments on commit 674e1c7

Please sign in to comment.