-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gatsby-transformer-remark): Allow for multiple different remark …
…sources (#7512) <!-- Q. Which branch should I use for my pull request? A. Use `master` branch (probably). Q. Which branch if my change is an update to Gatsby v2? A. Definitely use `master` branch :) Q. Which branch if my change is an update to documentation or gatsbyjs.org? A. Use `master` branch. A Gatsby maintainer will copy your changes over to the `v1` branch for you Q. Which branch if my change is a bug fix for Gatsby v1? A. In this case, you should use the `v1` branch Q. Which branch if I'm still not sure? A. Use `master` branch. Ask in the PR if you're not sure and a Gatsby maintainer will be happy to help :) Note: We will only accept bug fixes for Gatsby v1. New features should be added to Gatsby v2. Learn more about contributing: https://www.gatsbyjs.org/docs/how-to-contribute/ --> This PR allows for having more than one gatsby-transformer-remark plugin. With the addition of the `filter` option, the user can now decide which nodes should be handled by which plugin. For instance, with gatsby-source-filesystem, one could do the following in order to have multiple different markdown sources: ```js const plugins = [ { resolve: `gatsby-source-filesystem`, options: { path: `${__dirname}/src/pages`, name: `pages`, }, }, { resolve: `gatsby-source-filesystem`, options: { path: `${__dirname}/src/blog`, name: `blog`, }, }, { resolve: `gatsby-transformer-remark`, options: { filter: node => node.sourceInstanceName === `pages`, type: `MarkdownPage`, }, }, { resolve: `gatsby-transformer-remark`, options: { filter: node => node.sourceInstanceName === `blog`, type: `BlogPost`, }, } ] ``` I've also added a `type` option so that these different plugins create GraphQL types with different names. In the above example, we could expect that our markdown pages might have different frontmatter fields than our blog entries, but having them all under the `MarkdownRemark` type would force us to add filters on fields in order to only retrieve a list of either of them. Having different frontmatter formats would also pollute our GraphiQL documentation. Co-authored-by: Ward Peeters <[email protected]>
- Loading branch information
Showing
6 changed files
with
198 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.