-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make CodeExample block SSRd for better SEO. (#26829)
## Summary & Motivation We want to make sure that the CodeExample block is included in the statically generated HTML for the site so that it's included in SEO. Currently since we use a `useEffect` we only fetch the content on the client. To fix this we need to make sure we have the content on the server. To this end I added a check to see if we're on the server and if we are then we synchronously require the content for the codeblock inline during render and use it. Otherwise, if we're on the client, we import the content dynamically and rely on Suspense to avoid unmounting the SSR'd content during the initial render. ## How I Tested These Changes `yarn build` `yarn serve` Looked at the source in `view-source:http://localhost:3002/` and confirmed the HTML includes the codeblocks. There's a brief flash of the light theme but confirmed on the docs-preview site that this is in an existing issue and unrelated to my approach. https://github.com/user-attachments/assets/b760a941-1b77-4c46-b693-d0a79dff234e
- Loading branch information
Showing
2 changed files
with
70 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
151d6a9
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.
Deploy preview for dagster-docs-beta ready!
✅ Preview
https://dagster-docs-beta-7a7m7b40g-elementl.vercel.app
Built with commit 151d6a9.
This pull request is being automatically deployed with vercel-action