question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[gatsby-plugin-mdx] Code blocks on docs site are not pre-rendered

See original GitHub issue

Description

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

  1. Paste https://www.gatsbyjs.org/contributing/docs-templates/#plugin-readme-template into a browser
  2. Observe the section titled ‘Plugin README template’ does not scroll into view
  3. 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:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ascorbiccommented, Apr 7, 2020

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.

1reaction
ascorbiccommented, Mar 25, 2020

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found