-
Descriptiongatsby-remark-autolink-headers did not work correctly in a production mode and did not handle headers properly Steps to reproduce1. Does not work correctly in a production modeNote: In the develop mode, it works normally
code, how I handle this jumping behavior /// Simple jump to the header
import { navigate } from "gatsby";
navigate(`${location.pathname}#${anchor}`); 2. Did not handle headers properly
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
Hi, thanks for the issue! To make the process of resolving problems quicker for both sides we need you to fill out the issue template and give us a minimal reproduction: <!--
Please fill out each section below, otherwise, your issue will be closed. This info allows Gatsby maintainers to diagnose (and fix!) your issue as quickly as possible.
Useful Links:
- Documentation: https://www.gatsbyjs.com/docs/
- How to File an Issue: https://www.gatsbyjs.com/contributing/how-to-file-an-issue/
Before opening a new issue, please search existing issues: https://github.com/gatsbyjs/gatsby/issues
-->
## Description
Describe the issue that you're seeing.
### Steps to reproduce
Clear steps describing how to reproduce the issue. **Please** link to a reproduction, this makes your issue _much_ easier to diagnose (seriously).
How to Make a Minimal Reproduction: https://www.gatsbyjs.com/contributing/how-to-make-a-reproducible-test-case/
### Expected result
What should happen?
### Actual result
What happened.
### Environment
Run `gatsby info --clipboard` in your project directory and paste the output here. Also name any `flags` you use inside `gatsby-config.js`. |
Beta Was this translation helpful? Give feedback.
-
Sorry I did not fill in the issue in a fixed format! |
Beta Was this translation helpful? Give feedback.
-
Descriptiongatsby-remark-autolink-headers:
Steps to reproduce
this link shows the problem.
code, how I handle this jumping behavior /// Simple jump to the header
import { navigate } from "gatsby";
navigate(`${location.pathname}#${anchor}`); Expected result
Actual result
Environment> gatsby info --clipboard
System:
OS: Windows 10 10.0.19042
CPU: (12) x64 Intel(R) Core(TM) i5-10400 CPU @ 2.90GHz
Binaries:
Node: 14.16.1 - C:\Program Files\nodejs\node.EXE
npm: 6.14.12 - C:\Program Files\nodejs\npm.CMD
Languages:
Python: 3.9.4
Browsers:
Edge: Spartan (44.19041.1023.0), Chromium (91.0.864.59)
npmPackages:
gatsby: ~3.8.0 => 3.8.0
gatsby-plugin-image: ~1.8.0 => 1.8.0
gatsby-plugin-manifest: ~3.8.0 => 3.8.0
gatsby-plugin-material-ui: ~3.0.1 => 3.0.1
gatsby-plugin-mdx: ~1.4.0 => 1.4.0
gatsby-plugin-offline: ~3.7.0 => 3.7.1
gatsby-plugin-react-helmet: ~4.6.0 => 4.6.0
gatsby-plugin-sharp: ~3.8.0 => 3.8.0
gatsby-remark-autolink-headers: ~4.5.0 => 4.5.0
gatsby-remark-images: ~5.5.0 => 5.5.0
gatsby-remark-katex: ~3.1.26 => 3.1.26
gatsby-remark-prismjs: ~3.3.36 => 3.3.36
gatsby-source-filesystem: ~3.8.0 => 3.8.0
gatsby-transformer-sharp: ^3.8.0 => 3.8.0
npmGlobalPackages:
gatsby-cli: 3.3.0 resolve: `gatsby-remark-autolink-headers`,
options: {
maintainCase: true,
isIconAfterHeader: true,
}, no flags in gatsby-config.js |
Beta Was this translation helpful? Give feedback.
-
Regarding your two bullet points:
|
Beta Was this translation helpful? Give feedback.
Regarding your two bullet points:
You use a
pathPrefix
of/blog
and when you use thenavigate
function your resulting URL is:https://cangsdarm.github.io/blog/blog/archive/encryptingSaveGames/#Why?
So you have a double
/blog/blog
. There's no need to usenavigate
as the normal<a>
tag can already do what you want. Do have the same links as theid
that are set on the headings you should access thetableOfContents
field on themdx
node. You can find articles like these when searching for "Gatsby ToC": https://desktopofsamuel.com/how-to-create-a-scroll-tracking-table-of-content-in-gatsby/ or https://scottspence.com/2020/02/13/smooth-scroll-toc-gatsby/ or https://johno.com/mdx-table-of-conte…