[gatsby-plugin-mdx] Code blocks on docs site are not pre-rendered
See original GitHub issueDescription
Pasting https://www.gatsbyjs.org/contributing/docs-templates/#plugin-readme-template into Chrome, Firefox or Safari on Mac loads the correct page on the gatsbyjs.org website but the site doesn’t scroll to the correct location in the document.
I’ve checked the HTML in the dev tools and there is only one element on the page with that id
and it is on the correct h
element. There is also a right hand li
that references this id
and clicking it after the page loads does scroll the correct element into view - but, obviously, only after the page has fully loaded.
Steps to reproduce
- Paste https://www.gatsbyjs.org/contributing/docs-templates/#plugin-readme-template into a browser
- Observe the section titled ‘Plugin README template’ does not scroll into view
- Click the right hand side menu item titled: ‘Plugin README template’ and observe the correct section does scroll into view.
Expected result
The correct element should scroll into place upon page load.
Actual result
An element earlier in the page flow scrolls l into place upon page load.
Environment
This is on the gatsbyjs.org website itself.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
gatsby-plugin-mdx
gatsby -plugin-mdx is the official integration for using MDX with Gatsby. ... library like prism-react-renderer to render codeblocks using a React component.
Read more >Custom Code Blocks with MDX & Gatsby | Anna Rossetti
This guide will show you how to make your own custom code block component for your Gatsby site, but the general strategy is...
Read more >MDX renderer - Gatsby Site - <li>, <pre> and <code> tags not ...
Can you help me with what I need to do in order for MDXrenderer to work? I still need to figure out how...
Read more >Build a coding blog from scratch with Gatsby and MDX
Adding a Layout; Basic styling with styled-components; Code blocks with syntax highlighting; Copy code snippet to clipboard; Cover images for ...
Read more >Syntax highlighting with Gatsby, MDX, Tailwind and Prism ...
In this post I'll explain how I use the excellent {" "} Prism React Renderer by {" "} Formiddable to add syntax highlighting...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
OK, I’ve worked out what the problem is here. It’s nothing to do with the navigation. It seems the codeblocks aren’t being pre-rendered on the server. The page loads initially (and scrolls to the correct spot), but as soon as the page-data is loaded and the page is hydrated, then the code blocks appear, changing the length of the page.
Hi @saschwarz . Could you check if this is still happening, because I can’t reproduce it. I’ve tried clickign that link in FF, Safari and Chrome and each takes me to the correct section