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: use proper datetime to fix server-side/client-siode mismatch #5479

Merged
merged 4 commits into from
Jul 7, 2023

Conversation

ovflowd
Copy link
Member

@ovflowd ovflowd commented Jul 7, 2023

Description

This PR fixes two issues on the Node.js Website related to rendering.

  • The first issue is caused due to server-side/client-side Date rendering mismatch since the formatting function used is timezone-based. We updated the rendering of the time HTML elements by using JavaScript's built-in toLocaleString function. We've forced a UTC timezone and use en-GB locale information.
  • The second issue is caused when the MDX-generated contents are identical, and the comparison of the theme.tsx memoization asserts both props as being the same as the comparison only used the MDX content as a comparison, excluding other props such as frontmatter. This should fix Next.js, not "moving" to another page. (The issue is that a re-rendering would not occur).
  • This PR also removes the strftime package and utilities that are not used anymore.

Fixes #5478

@ovflowd ovflowd added bug fast-track Fast Tracking PRs infrastructure Issues/PRs related to the Repository Infra labels Jul 7, 2023
@ovflowd ovflowd requested a review from a team as a code owner July 7, 2023 16:28
@vercel
Copy link

vercel bot commented Jul 7, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nodejs-org ✅ Ready (Inspect) Visit Preview Jul 7, 2023 4:28pm
nodejs-org-stories ✅ Ready (Inspect) Visit Preview Jul 7, 2023 4:28pm

Copy link
Collaborator

@bmuenzenmeyer bmuenzenmeyer left a comment

Choose a reason for hiding this comment

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

Confirmed in the preview that the behavior reported within #5478 is resolved

@ovflowd ovflowd merged commit 201d2e3 into main Jul 7, 2023
@ovflowd ovflowd deleted the fix/multiple-minor-fixes branch July 7, 2023 16:52
@ovflowd
Copy link
Member Author

ovflowd commented Jul 7, 2023

@bmuenzenmeyer Could you maybe open an issue regarding we providing a generic Component for the <time> element?

The component should have two props: date, which should be a string or Date object and the second one. corresponding to the shape of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#options

The component should return a time element, with the DateTime formatted on the currently applied locale (so the component must use useLocale hook).

@ovflowd
Copy link
Member Author

ovflowd commented Jul 7, 2023

@bmuenzenmeyer on the above, if you feel like you can introduce a component quickly enough, no need to open an issue if you feel like doing it. Shouldn't take enough time.

And this would allow the formatted times to actually be shown in the language/date format of the currently applied locale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fast-track Fast Tracking PRs infrastructure Issues/PRs related to the Repository Infra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Page content does not update when navigating from "News" to "Downloads" page
3 participants