Skip to content
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

feat(gatsby): override default options of gatsby-plugin-page-creator #17379

Closed
wardpeet opened this issue Sep 4, 2019 · 7 comments · Fixed by #17420
Closed

feat(gatsby): override default options of gatsby-plugin-page-creator #17379

wardpeet opened this issue Sep 4, 2019 · 7 comments · Fixed by #17420
Assignees
Labels
good first issue Issue that doesn't require previous experience with Gatsby help wanted Issue with a clear description that the community can help with.

Comments

@wardpeet
Copy link
Contributor

wardpeet commented Sep 4, 2019

Summary

When a user specifies a gatsby-plugin-page-creator plugin with a path pointing to src/pages we replace the config of our default gatsby-plugin-page-creator in gatsby core. This allows people to add ignore options.

A step in the right direction:

  1. open https://github.com/gatsbyjs/gatsby/blob/abf888147de0c87d5c8560eaf2de18a0da4b5fca/packages/gatsby/src/bootstrap/load-plugins/load.js
  2. find a gatsby-plugin-page-creator plugin with the path pointing to src/pages and temporary save the config in a variable
  3. Replace the options on line ( ) with your variable.
  4. write tests to make sure this works correctly.

Basic example

// in gatsby-config.js
{
  plugins: [{
    resolve: require.resolve(`gatsby-plugin-page-creator`),
    options: {
      path: `${__dirname}/src/pages`,
      ignore: [`**/examples/**`],
    },
  }]
}

Should change the default gatsby-plugin-page-creator config in

plugins.push(
processPlugin({
resolve: require.resolve(`gatsby-plugin-page-creator`),
options: {
path: slash(path.join(program.directory, `src/pages`)),
pathCheck: false,
},
})
)

Outcome should be

  plugins.push(
    processPlugin({
      resolve: require.resolve(`gatsby-plugin-page-creator`),
      options: {
        path: slash(path.join(program.directory, `src/pages`)),
        ignore: [`**/examples/**`],
      },
    })
  )

Motivation

We get a lot of requests to override the default gatsby-plugin-page-creator plugin. At this point we don't offer a good solution for this problem, there is a workaround but it's not fixing all use cases.

@wardpeet wardpeet added help wanted Issue with a clear description that the community can help with. good first issue Issue that doesn't require previous experience with Gatsby effort: low labels Sep 4, 2019
@wardpeet wardpeet changed the title feat(gatsby): override default options feat(gatsby): override default options of gatsby-plugin-page-creator Sep 4, 2019
@akshayymahajan
Copy link
Contributor

Hey @wardpeet! I would like to work on this issue.

@wardpeet
Copy link
Contributor Author

wardpeet commented Sep 5, 2019

Nice! Please let us know if we can assist with anything. We suggest opening a draft/WIP PR if you having questions so we can give pointers on specific areas.

Thank you for contributing! ❤️

@akshayymahajan
Copy link
Contributor

My PR is failing e2e tests even though all other tests are passing in my local dev environment. Any idea @wardpeet

@sidharthachatterjee
Copy link
Contributor

Fixed and published in gatsby@2.15.11 thanks to @akshayymahajan 🥇

@karlhorky
Copy link
Contributor

karlhorky commented Sep 11, 2019

Thanks @sidharthachatterjee @akshayymahajan @wardpeet !

This is working with the following config in my gatsby-config.js (needed to remove the require.resolve from @wardpeet's first description):

{
  resolve: `gatsby-plugin-page-creator`,
  options: {
    path: `${__dirname}/src/pages`,
    ignore: [`**/examples/**`],
  },
},

@siddharthkp
Copy link
Contributor

@karlhorky We meet again! Put you've got the wrong Sid this time 😛 (you want @sidharthachatterjee)

@karlhorky
Copy link
Contributor

🤦‍♂️ Ah oops, sorry Siddharth! Tagged Sidhartha now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issue that doesn't require previous experience with Gatsby help wanted Issue with a clear description that the community can help with.
Projects
None yet
5 participants