bazel-contrib / bcr-ui

Website for the Bazel Central Registry
https://registry.bazel.build
Apache License 2.0
15 stars 8 forks source link

Re-render relative dates on client side to display correct value #57

Closed hobofan closed 1 year ago

hobofan commented 1 year ago

CLOSES #27

This will render all relative dates present on the pages again in the browser, so that they show the correct relative values to the current time. As this leads to a DOM that differs from the server-rendered DOM, we need to use suppressHydrationWarning for the rendering locations. Without that, we would get some React errors, leading to e.g. broken navigation.

As we now base all rendering on authorDateIso, the redundant old variants that contained the pre-rendered relative date string have been removed from the staticProps, reducing the size of the data blob that will be served to the frontend.


Flow to test (might be easier with libfaketime, but I didn't get that to be respected in the Next.js build):