Docsify: Linking to a # heading in a page on the sidebar

Created on 6 Jan 2018  路  3Comments  路  Source: docsifyjs/docsify

I want to link to a specific heading in a page (for example, # here) that's about halfway down the page on the sidebar, but I don't know to. Any pointers?

question

Most helpful comment

_sidebar.md

[home](/home#here)
[home](/home.md#here)
[home](/home?id=here)

All will be compiled to

<a  href="/#/home?id=here">home</a>

All 3 comments

_sidebar.md

[home](/home#here)
[home](/home.md#here)
[home](/home?id=here)

All will be compiled to

<a  href="/#/home?id=here">home</a>

Thanks!

Note, one example @QingWei-Li didn't mention. The following:

[see](/#here)

becomes

<a href="/#/the-current-page?id=here">see</a>

It would be great to have this functionality for <a> tags too!

There are some cases where it is not possible to use the []() syntax.

For example, I want to make some tables, but GitHub-flavored markdown does not support cells with multi-line content, so I need to make my table using <table>, and due to the nesting it is difficult to place markdown inside the <td> table cells. But it is easy to place <a> tags inside the table cells.


I have a couple ideas:

  1. if using vue, perhaps docsify could pass currentPage inside the props that go into the markdown template, then it would be possible to write sub-section links without caring what particular page we are in like this:

    <a :href="currentPage + '#some-section'"></a>
    
  2. Docsify could also have a setting that allows the content of <a href="..." to be handled the same as with [](...) syntax, so that it will map stuff like #some-id to #/the-current-page?id=some-id

    f.e., the following

    <a href="#here">see</a>
    <a href="?id=here">see</a>
    
    <a href="home#here">see</a>
    <a href="home.md#here">see</a>
    <a href="home?id=here">see</a>
    

    would become

    <a href="/#/the-current-page?id=here">see</a>
    <a href="/#/the-current-page?id=here">see</a>
    
    <a href="/#/home?id=here">see</a>
    <a href="/#/home?id=here">see</a>
    <a href="/#/home?id=here">see</a>
    
Was this page helpful?
0 / 5 - 0 ratings