-
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
Documentation fix: Execute trailing slash stripping function, rather than assign it. #9924
Conversation
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.
Left a comment!
@@ -121,7 +121,7 @@ exports.onCreatePage = ({ page, actions }) => { | |||
return new Promise(resolve => { | |||
const oldPage = Object.assign({}, page) | |||
// Remove trailing slash unless page is / | |||
page.path = _path => (_path === `/` ? _path : _path.replace(/\/$/, ``)) |
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.
If we're going to go this route, why not create a function (e.g. const replacePath = _path => // yadda yadda
) and then use it like the link you provide? That seems much clearer!
What do you think?
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.
Absolutely, I guess I just went for the single line change for the sake of keeping it to one line! PR updated
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.
Looks good; thank you!
Holy buckets, @stevetweeddale — 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! |
…than assign it. (gatsbyjs#9924) The trailing slash stripping plugin [executes the function](https://github.com/gatsbyjs/gatsby/blob/f9714a5646523bc728586e3692190507ad68e6c1/packages/gatsby-plugin-remove-trailing-slashes/src/gatsby-node.js#L9) rather than just assigning it, so I'd imagine that's what the example code should be doing too.
The trailing slash stripping plugin executes the function rather than just assigning it, so I'd imagine that's what the example code should be doing too.