-
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-plugin-netlify): Allow status codes in redirects (#11255) #11484
Conversation
This addresses #11255. A request to implement support for status codes other that 301/302 for this plugin, as Netlify also supports other status codes. @sidharthachatterjee suggested I submitted a PR with my proposed changes, and this is that PR. It adds one option to the `createRedirect` call which is `statusCode`. You can use it to manually set the status code. If it's not set, the status code will be determined by the `isPermanent` option as before (`301` if `true` or `302` if not (the default) ). I've also updated the README to document this new feature.
Thank you so much, @joostdecock Could you please rebase over master once? I think Prettier behaviour changed from the last version and that's why we're seeing the linting errors |
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 some small documentation stuff, otherwise LGTM!
Co-Authored-By: joostdecock <joost@decock.org>
My bad. I hand-edited the table markup to make it prettier but it seems prettier didn't agree. |
We'd need to update the docs too https://www.gatsbyjs.org/docs/actions/#createRedirect |
I assumed this documented the Gatsby Which is why I figured this should only be documented in the plugin README. If you disagree, I'd be happy to take a stab at updating the documentation, but I assumed it was intentionally not included in the Gatsby API docs. If you can advice on the best course of action, I'd be happy to work on it. |
As this has gone cold a bit, I figured I'd let you know that I'm still happy to update the documentation. But before doing so, someone would need to decide whether it's needed or not (see my earlier question). |
I agree with @joostdecock that updating the createRedirect docs shouldn't be necessary since this only affects the netlify-plugin |
So this is tough decision to make, because gatsby core itself can't do anything with There is at least one other plugin (that I'm aware of) - @jariz As maintainer of |
My gut feel right now is to merge as-is and we can discuss adding |
A plugin that requires a field creates a defacto standard. If we're going to add support to the plug-in, we should document it. |
Thanks for the mention @pieh. |
@jariz You obviously can implement this as well, but my worry is that there are other plugins (that I'm not aware of) that implement that feature. But I think You raised very valid point that we should document it in @joostdecock We are in alignment here that we should document this option in https://www.gatsbyjs.org/docs/actions/#createRedirect |
That's great. I took a first stab and updated the (inline) docs. In've added the @jariz I've added your S3 plugin as an example, but it would be nice if you could check whether the way I phrased things works out for you. Thanks in advance for your feedback. (edited for typos) |
@joostdecock lgtm! |
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.
LGTM too! Thanks @joostdecock for implementation and @jariz for feedback!
Holy buckets, @joostdecock — we just merged your PR to Gatsby! 💪💜 Gatsby is built by awesome people like you. Let us say “thanks” in two ways:
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! |
Description
This addresses #11255. A request to implement support for status
codes other that 301/302 for this plugin, as Netlify also supports
other status codes.
@sidharthachatterjee suggested I submitted a PR
with my proposed changes, and this is that PR.
It adds one option to the
createRedirect
call which isstatusCode
.You can use it to manually set the status code. If it's not set, the
status code will be determined by the
isPermanent
option as before(
301
iftrue
or302
if not (the default) ).I've also updated the README to document this new feature.
Related Issues
Fixes #11255