signalwerk / gatsby-remark-table-of-contents

gatsby remark plugin to generate table of contents
21 stars 10 forks source link

Anchor links are not working #3

Closed keul closed 4 years ago

keul commented 4 years ago

While the TOC is properly generated, links inside the page are not working.

Inspecting the DOM I don't see any named link or id on the header elements.

Can this be related to other gatsby-transformer-remark plugins?

For example: is I put the gatsby-remark-table-of-contents as the last of the list it totally stop working (even the TOC is not generated).

This is my configuration:

    {
      resolve: `gatsby-transformer-remark`,
      options: {
        plugins: [
          {
            resolve: `gatsby-remark-table-of-contents`,
            options: {
              exclude: "Table of Contents",
              tight: true,
              fromHeading: 1,
              toHeading: 6,
            },
          },
          {
            resolve: `gatsby-remark-images`,
            options: {
              maxWidth: 590,
            },
          },
          {
            resolve: `gatsby-remark-responsive-iframe`,
            options: {
              wrapperStyle: `margin-bottom: 1.0725rem`,
            },
          },
          `gatsby-remark-prismjs`,
          `gatsby-remark-copy-linked-files`,
          `gatsby-remark-smartypants`,
        ],
      },
    },

The "lowest" position where I'm able to put the configuration is above gatsby-remark-prismjs.

lharries commented 4 years ago

@keul you need to install gatsby-remark-autolink-headers. I just had the same problem. I've created a PR #4 to improve the installation instructions

signalwerk commented 4 years ago

@keul sorry I didn't see your issue. @lharries just added a clear instruction to the readme. does that solves your problem?

keul commented 4 years ago

@signalwerk @lharries I'll check this ASAP and I'll be back to you in case

keul commented 4 years ago

It works like a charm! Thanks

signalwerk commented 4 years ago

awesome!