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

fix(gatsby): Allow overriding options for default instance of gatsby-plugin-page-creator #17420

Conversation

akshayymahajan
Copy link
Contributor

Description

Override the default options for gatsby-plugin-page-creator with options specified in gatsby-config.js

Related Issues

Fixes #17379

@akshayymahajan akshayymahajan requested a review from a team as a code owner September 5, 2019 16:11
@akshayymahajan
Copy link
Contributor Author

This is my first attempt at contributing to gatsbyjs, would really appreciate some feedback..

…ons specified in gatsby-config.js only if options.path matches src/pages
@karlhorky
Copy link
Contributor

Hm, seems like this 1) added by themes can be shadowed test is failing:

CypressError: Timed out retrying: Expected to find element: '[data-testid="title"]', but never found it.

https://circleci.com/gh/gatsbyjs/gatsby/217604?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link

Not sure what that could be, maybe unrelated to this? Wonder if master is currently passing...

@akshayymahajan
Copy link
Contributor Author

Yes @karlhorky. But when I try to run the same e2e test locally on my system, it passes all the tests without any issue..

@muescha
Copy link
Contributor

muescha commented Sep 6, 2019

Somehow at a first glimpse the code not do the expected...

A) it overwrites the plugin options with default. But it should be otherwise. The default with the specific

B) if there found the plugin with the same path it should not pushed a second time.

As I understand the documentation of the plugin:

a) it is by default activated (pushed to plugins)
b) if it defined manually in plugins it uses the new options (overwriting options from default one)
c) no additional push of the plugin at the end if there is a manual defined plugin with /src/pages

@wardpeet could confirm my assumptions?

const pageCreatorPlugin = config.plugins.find(
plugin =>
plugin.resolve === `gatsby-plugin-page-creator` &&
plugin.options.path.match(/src\/pages$/)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should not match only the last chars but the full path, because all path for this plugin are full path

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be also ${__dirname}/myguides/src/pages

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the condition to override the defaults only if the path matches <program.directory>/src/pages

Copy link
Contributor

@sidharthachatterjee sidharthachatterjee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for picking this up @akshayymahajan 👍

@sidharthachatterjee sidharthachatterjee changed the title Override the default options for gatsby-plugin-page-creator fix(gatsby): Allow overriding options for default instance of gatsby-plugin-page-creator Sep 9, 2019
@sidharthachatterjee sidharthachatterjee added the bot: merge on green Gatsbot will merge these PRs automatically when all tests passes label Sep 9, 2019
@gatsbybot gatsbybot merged commit 9bdeda4 into gatsbyjs:master Sep 9, 2019
@gatsbot
Copy link

gatsbot bot commented Sep 9, 2019

Holy buckets, @akshayymahajan — we just merged your PR to Gatsby! 💪💜

Gatsby is built by awesome people like you. Let us say “thanks” in two ways:

  1. We’d like to send you some Gatsby swag. As a token of our appreciation, you can go to the Gatsby Swag Store and log in with your GitHub account to get a coupon code good for one free piece of swag. We’ve got Gatsby t-shirts, stickers, hats, scrunchies, and much more. (You can also unlock even more free swag with 5 contributions — wink wink nudge nudge.) See gatsby.dev/swag for details.
  2. We just invited you to join the Gatsby organization on GitHub. This will add you to our team of maintainers. Accept the invite by visiting https://github.com/orgs/gatsbyjs/invitation. By joining the team, you’ll be able to label issues, review pull requests, and merge approved pull requests.

If there’s anything we can do to help, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’.

Thanks again!

@sidharthachatterjee
Copy link
Contributor

Published in gatsby@2.15.11

@akshayymahajan akshayymahajan deleted the feature/override-options-gatsby-plugin-page-creator branch September 9, 2019 06:09
@akshayymahajan akshayymahajan restored the feature/override-options-gatsby-plugin-page-creator branch September 9, 2019 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: merge on green Gatsbot will merge these PRs automatically when all tests passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(gatsby): override default options of gatsby-plugin-page-creator
5 participants