ID generation with umlauts lead to bad links in table of contents
See original GitHub issueVersion
@nuxt/content: v1.11.1 nuxt: v2.14.12
Reproduction Link
https://codesandbox.io/s/jovial-cray-sphhr?file=/content/index.md:55-119
Steps to reproduce
On the index page, you can not follow the h2 anchor with the umlauts “Ü”.
What is Expected?
The anchor should be reachable.
What is actually happening?
The TOC-example snippet is correct, it encodes the anchor link to https://sphhr.sse.codesandbox.io/#über-uns---does-not-work
The output produced by <nuxt-content />
creates an ID to follow that is not escaped: id="über-uns---does-not-work"
.
There are two approaches:
a) Avoid URL escaping in the TOC snippet with <a :href="
#${link.id}">{{ link.text }}</a>
instead.
b) Strip all non-standard characters from TOC and ID generation.
Sadly even Github has its problem with the same topic: https://github.com/adrianrudnik/md-umlauts-test
Clicking the anchor icon in front produces #über-uns---does-not-work
, right clicking the anchor icon > copy link will produce #%C3%BCber-uns---does-not-work
, so no guidance there.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:6
Top GitHub Comments
I just ran into this issue as well and created a small hacky fix to throw into your _slug.vue till this gets properly fixed.
Hi,
I also ran into this issue and I completed @wirk’s solution to also slugify anchors:
(Updated to allow external links)