-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds gatsby-source-swiftype
to theme
#185
Conversation
createNodeId, | ||
}); | ||
|
||
createParentChildLink({ parent: node, child: child }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing that in order to get the related resources we'll query for the children of the node?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR is just copying what we had before. I didn't write the original code, but I believe we need to establish a relationship so that we can query related content for a specific page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. This creates a childrenRelatedPages
(if I remember correctly) field on the parent so that you can query for it for the current page.
pluginOptions | ||
) => { | ||
const { createNode, createParentChildLink } = actions; | ||
const { filterNode = () => false, getPath } = pluginOptions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does this filterNode
function do? how does this inline function work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this is being used as a default value in case filterNode
isn't specified. If we use this plugin without filterNode
, it will just be a function that always returns false
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason that filterNode
returns false
rather than true
is that we want to avoid executing searches on Swiftype for pages that aren't explicitly set as needing related resources. This helps us avoid the cost of executing a query against Swiftype for pages that we don't use this for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this all looks good to me! just two clarifying questions, and the one suggestion that I have is that we change the name of the plugin to gatsby-source-related-resources
? It just makes sense to me since we are sourcing the related resources, but feel free to challenge me on this!
@caylahamann Let me know if you have any additional questions on this PR. cc: @jerelmiller (this PR brings the work you did on the developer site into the theme so that we have the option of getting related content on other sites) |
TODO: Write docs |
Description
This PR copies the
gatsby-source-swiftype
plugin that we created for the developer site to the theme and exposes an optionalswiftype
option that can be passed to the theme by any site using the theme. This will allow us to use this logic for both the developer site and the new docs site.Reviewer Notes
I'm not 100% that we can have local plugins in a theme like this. Once this is merged and released, I'll work on swapping the developer site over to use the plugin via the theme (I'll link that PR here for transparency).
Related Issue(s)