-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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-page-utils): extract logic for watching a directory from gatsby-page-creator so can reuse for custom page creation #14051
feat(gatsby-page-utils): extract logic for watching a directory from gatsby-page-creator so can reuse for custom page creation #14051
Conversation
Can you add to the description some sample code showing how someone would use this in their gatsby-node.js? |
Should |
Yeah, what @pieh said. That should be part of this PR. |
Sure I'll add it as soon as I figure out how to extract watching directory functionnality. I have difficulties to know to limit of things to extract. What function signature did you have in mind @KyleAMathews ? Maybe someone could help on this part by pairing ? |
Maybe someone from @gatsbyjs/core could answer my question about function signature of the watching directory functionnality ? 😄 |
@frinyvonnick Sorry for dropping the ball here! The API could look something like that: watchDirectory(
path: String;
glob: String;
onNewFile: (newPath) => void;
onRemovedFile: (removedPath) => void;
): Promise<undefined> It should track which files were already created and which were not. |
Thank you @freiksenet, I'll go with it 👌! |
1dede38
to
dc933ba
Compare
@KyleAMathews I added some documentation and an example in the README.md. Is this good for you ? Should I add documentation somewhere else ? @freiksenet I implemented the signature you suggested. Seems good to you ? @gatsbyjs/core can't figure out how to make e2e passes ? Could someone help me on this subject ? |
mmh let me look into this properly |
Fingers crossed 🤞. gatsby-dev didn't copy the plugin as it was a name mismatch between package.json & foldername. Also the watchDirectory export wasn't a default export but I changed all exports to commonjs (require) to be consistent. |
Yeah it works 🎉 thanks for your help @wardpeet! Sorry for the typo 😕 |
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.
just my suggestions and nitpicks
Co-Authored-By: Michael <184316+muescha@users.noreply.github.com>
Co-Authored-By: Michael <184316+muescha@users.noreply.github.com>
Co-Authored-By: Michael <184316+muescha@users.noreply.github.com>
Thank you for your review @muescha 👍 |
No need to say sorry, it happens to the best of us 😉 Thanks for doing this! |
@wardpeet this is ready to be merged, no ? 😄 |
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.
Oh yeah definitely, the code looks great.
Description
It extract logic from
gatsby-plugin-page-creator
to help creating pages:Related Issues
Closes #13606