Jakub Holý
Jakub Holý

Reputation: 6205

Why isn't gatsby-transformer-remark adding IDs to headings so that I could link to them?

I believe(d) that gatsby-transformer-remark automatically adds IDs to each heading so that you can link to them. Its tableOfContents generates links to such IDs yet my headings do not have them. Why? It should work as it does here https://using-remark.gatsbyjs.org/hello-world-kitchen-sink/ (which also adds gatsby-remark-autolink-headers for fancy effects).

See an example here https://blog.jakubholy.net/it-will-only-take-1h/, the code is at https://github.com/holyjak/blog.jakubholy.net

Thank you!

Upvotes: 5

Views: 2044

Answers (2)

adrian
adrian

Reputation: 2923

You can use the gatsby-remark-heading-slug plugin which uses github-slugger to add IDs for you without any of the additional complexity of gatsby-remark-autolink-headers.

Upvotes: 1

Derek Nguyen
Derek Nguyen

Reputation: 11577

gatsby-transformer-remark automatically adds IDs to each heading

It doesn't, it's solely the work of gatsby-remark-autolink-headers. Autolink-headers is not only there for fancy effect, it actually generates the id for each header using github-slugger.

You can see the implementation detail here

Upvotes: 13

Related Questions