GitbookIO / gitbook

The open source frontend for GitBook doc sites
https://www.gitbook.com
GNU General Public License v3.0
27.23k stars 3.88k forks source link

Serve the correct status code for not found and redirects 👌 #2582

Open gregberge opened 2 days ago

gregberge commented 2 days ago

By reading the code, we are already fetching things in generateMetadata that is awaited before the first streaming chunk is emitted. So actually the streaming is not active when we load the first page.

Giving that, the only issue to solve was to enable streaming when we switch to a page dynamically (from the sidebar). By wrapping page content into React.Suspense it's now working.

So this PR gives exactly the same result as before but it provides the good status code and redirect code.

Also refactor the code to mutualize things better.


This does not work because Next.js is waiting for generateMetadata if there is no loading.tsx present. The problem is that streaming and instant loading are activated by the same thing: loading.tsx.

I am now trying to use the parallel routing to put a loading.tsx only for nav routing.


Solve RND-4299

changeset-bot[bot] commented 2 days ago

⚠️ No Changeset found

Latest commit: dc4b7a1cdc6648bf8414f8951fed481929c469b9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

github-actions[bot] commented 2 days ago

GitBook Preview Latest commit: https://9d01e95f.gitbook-open.pages.dev PR: https://pr2582.gitbook-open.pages.dev

argos-ci[bot] commented 2 days ago

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ⚠️ Changes detected (Review) 18 changed Nov 24, 2024, 9:04 PM