-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Writing cohort banner #10078
Writing cohort banner #10078
Conversation
✅ ethereum-org-website-dev deploy preview ready
|
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! I left a comment for improvement.
const WritersCohortBanner = () => { | ||
if ( | ||
typeof window !== `undefined` && | ||
window.location.pathname.includes("contributing") |
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.
For SSR purposes, a better way of getting the pathname
is from Gatsby itself (or specifically from reach router which is what they use underneath).
// every page or template receives a `location` prop
const StaticPage = ({ data, location }) => {
...
}
// then you can pass that prop down to the components
<WritersCohortBanner pathname={location.pathname} />
This way you abstract yourself from the window
object and you can render the same thing server and client side.
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.
Makes sense, changed this PR over to this just now.
Co-authored-by: Joshua <62268199+minimalsm@users.noreply.github.com>
Co-authored-by: Pablo Pettinari <pettinarip@gmail.com>
Description