valeriangalliat / markdown-it-anchor

A markdown-it plugin that adds an `id` attribute to headings and optionally permalinks.
The Unlicense
292 stars 72 forks source link

Specifying a base URL in a Nuxt app breaks the links #59

Closed lobo-tuerto closed 5 years ago

lobo-tuerto commented 5 years ago

Hello,

After doing something like this in nuxt.config.js:

router: {
    base: process.env.NODE_ENV === 'production'
      ? '/zeta/'
      : '/'
  }

All header anchors break and direct the user to the root of the app. Is there anything I can configure so it works as it should?

Live article that exhibits the behaviour: https://lobotuerto.com/zeta/blog/vuejs-components-inside-markdown

Try clicking on anything on the TOC, or the § links besides the headers in the main content.

lobo-tuerto commented 5 years ago

It even breaks in dev mode too, with '/' or '' as base.

nagaozen commented 5 years ago

404 Not Found - Also, Nuxt is downstream.

atinux commented 4 years ago

Actually, this is a browser issue directly: https://rogerkeays.com/blog/using-base-href-with-anchors

You can take a look at this workaround: https://github.com/nuxt/content/issues/376#issuecomment-702193217