EDU-16758: fix API reference endpoint deep links rendering as overview#1261
EDU-16758: fix API reference endpoint deep links rendering as overview#1261PedroAntunesCosta wants to merge 1 commit into
Conversation
…ndpoint deep links
❌ Deploy Preview for elated-hoover-5c29bf failed. Why did it fail? →
|
|
All tests were successful! |
3ca8c4b to
8825c7e
Compare
|
Closing this PR — it has been superseded by #1264. WhyThis PR's branch ( PR #1264 re-lands PR #1226 + this PR's hash-detection fix as a single branch off post-revert
The deploy preview on #1264 is green: https://deploy-preview-1264--elated-hoover-5c29bf.netlify.app What was actually wrongPostmortem TL;DR: this PR's hash fix and the Netlify deploy failure are causally unrelated — the deploy issue first manifested on PR #1260 (a navigation JSON edit) hours before this PR was opened, and the trigger appears to be a Netlify/AWS infra-side tightening rather than anything in this branch. The hash-detection fix you wrote here is shipping verbatim in #1264. Nothing about your code was the problem. |
Fixes a regression introduced by PR #1226 (
feat/api-reference-seo-indexing) where every deep link to an API reference endpoint — e.g./docs/api-reference/foo#get--endpoint— rendered the overview page instead of the interactive RapiDoc endpoint view.Changes
clientHashstate populated fromwindow.location.hashon mount and onhashchange, replacing the previousrouter.asPath-only detection.router.asPathparsing when the client hash is empty, preserving the legacy?endpoint=behavior.Why
The SEO indexing PR introduced conditional rendering between the SSR-friendly overview HTML and the client-only RapiDoc element, gated by
isOverview = endpointPath === slug. That flag was derived fromrouter.asPath, but Next.js does not include the URL hash inasPathduring SSR or on the initial client hydration of a directly-loaded URL. As a result, any direct link with a hash hydrated as the overview and never re-rendered into the endpoint view. Readingwindow.location.hashafter mount restores the previous behavior without changing the SSR output.Notes
useState('')produces the same overview HTML the server already rendered, so the SEO improvements from EDU-16758: Improve API reference SEO and indexing #1226 are preserved.hashchangelistener, which now also feedsclientHash.Related Task
EDU-16758