Skip to content

[[toc]] only generate same link when two or more headers are same #2030

Open
@puiiyuen

Description

@puiiyuen
  • I confirm that this is an issue rather than a question.

Bug report

When there are two or more headers in same name, the [[toc]] only generates one link for all same name headers. Other headers cannot be navigated to the right positions. Btw, the sidebar works well!

Steps to reproduce

# Test toc

[[toc]]

## Header 1
<!-- same header name -->
### Header 2
- Under *first* header 2 
- Under *first* header 2 

### Header 3
- Under header 3

## Header 4
<!-- same header name -->
### Header 2
- Under *second* header 2 
- Under *second* header 2 

What is expected?

They should be different links:
First "Header 2": localhost:8000/docs/test/test.html#header-2
Second "Header 2": localhost:8000/docs/test/test.html#header-2-2

What is actually happening?

They are same:
First "Header 2": localhost:8000/docs/test/test.html#header-2
Second "Header 2": localhost:8000/docs/test/test.html#header-2

Other relevant information

  • Output of npx vuepress info in my VuePress project:
    Environment Info:
  System:
    OS: macOS 10.15.1
    CPU: (8) x64 Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
  Binaries:
    Node: 13.1.0 - /usr/local/bin/node
    Yarn: 1.19.1 - /usr/local/bin/yarn
    npm: 6.13.1 - /usr/local/bin/npm
  Browsers:
    Chrome: 78.0.3904.70
    Firefox: Not Found
    Safari: 13.0.3
  npmPackages:
    @vuepress/core: Not Found
    @vuepress/theme-default: Not Found
    vuepress: Not Found
  npmGlobalPackages:
    vuepress: 1.2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions