facebook / docusaurus

Easy to maintain open source documentation websites.
https://docusaurus.io
MIT License
55.66k stars 8.34k forks source link

Cannot move to another page's anchor #2901

Closed shinout closed 3 years ago

shinout commented 4 years ago

πŸ› Bug Report

Cannot move to another page's anchor when clicking the link.

Have you read the Contributing Guidelines on issues?

yes

To Reproduce

  1. Add a page named "doc1" with the following contents

    ## foo
    here require large contents enough to scroll
    ...
    ...
    ...
    ...
    ...
    
    ## bar
    some contents
  2. Add a page named "doc2" with the following contents
    [link to another page's anchor](doc1#bar)
  3. Build the pages and open the browser
  4. Click the link at the page "doc2"

Expected behavior

Move to the "bar" on the page "doc1"

Actual Behavior

Just move to the page "doc1", but the scroll position is incorrect (=top).

Your Environment

Reproducible Demo

https://shinout.github.io/docusaurus-incorrect-anchor-move-repro/docs

teikjun commented 4 years ago

This should work as intended if you use lowercase, i.e. doc1#images instead of doc1#Images

yangshun commented 4 years ago

Indeed! Anchor links are slugified hence will become lower case. Thanks Teik Jun! Hi there fellow πŸ‡ΈπŸ‡¬ -ean!

teikjun commented 4 years ago

Hi Yangshun! :D

shinout commented 4 years ago

Thank you for your help. Then I'm wondering how to link multibyte strings. I use Japanese and this happens when an anchor contains some Japanese characters. It won't work well.

slorber commented 4 years ago

Hi @shinout, if you think we should reopen, can you make a repro please?

teikjun commented 4 years ago

I've made a repro for the issue mentioned by @shinout

To Reproduce:

  1. Visit https://docusaurus-anchor-repro.now.sh/docs/doc2
  2. Click "go to a header written in japanese" link

It goes to the start of the page instead of the actual header

Reproducible Demo: Repo: https://github.com/teikjun/docusaurus-anchor-repro

yangshun commented 4 years ago

@teikjun Thank you for that! Btw are you an MLH fellow? Just wondering about the increased interaction here πŸ˜ƒ

teikjun commented 4 years ago

Yup, I'm an MLH Fellow! I heard about the fellowship from your tweet πŸ˜„

yangshun commented 4 years ago

Oh that's great! Look @JoelMarcey I hired a fellow without knowing πŸŽ‰

JoelMarcey commented 4 years ago

Welcome @teikjun!!

shinout commented 4 years ago

@teikjun Thank you for preparing reproduction! @yangshun Thanks for reopen the issue.

Should I add to the title of this issue when using multibyte string ?