Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"href" of sidebar headers #1069

Closed
1 task
Erimus-Koo opened this issue Mar 13, 2020 · 4 comments · Fixed by #1336
Closed
1 task

"href" of sidebar headers #1069

Erimus-Koo opened this issue Mar 13, 2020 · 4 comments · Fixed by #1336

Comments

@Erimus-Koo
Copy link

Bug Report

This maybe should be a feature request, I'm not sure.
I just tell what happen and what I expect.

Steps to reproduce

In markdown file, wrote a header with link, like:

## [chapter](https://wikisource.com/chapter)

and use sidebar.

What is current behaviour

In sidebar, if you click chapter and chapter is a normal header(without link), it will guide you to the position(y scroll) of chapter in page. (this is normal case)

But if the chapter header has had a href, click the title chapter in sidebar, will open a new page with "https://wikisource.com/chapter".

What is the expected behaviour

In sidebar, whether or not I have a link, click should always bring me to the correct position in the doc.

And if I click the "chapter" header (with link) in the doc, then go open the link in new page.

Sidebar should always be a “navigation”, a guide to position in doc, not to outside.

Other relevant information

  • Bug does still occur when all/other plugins are disabled?

Your OS: win10 1909
Node.js version: 10.12.0
npm/yarn version: 6.4.1
Browser version: chrome Version 80.0.3987.132 (Official Build) (64-bit)
Docsify version: 4.11.2
Docsify plugins: I've remove all plugins, its same.


I've tried to change it like

## chapter [🔗](https://wikisource.com/chapter)

The sidebar will display "chapter-🔗", in two lines (because of css display:block).
Click chapter, go the position in doc, it works. And click 🔗, go outside site page, its fine. Then I can modify the css to make them in one line.

But I still wish you can consider about this.
And thanks for your time.

@anikethsaha
Copy link
Member

Just to confirm what I understood.

You have a link in sidebar (chapter) which has some external links
now when clicking the sidebar link, it should open the page and on that page the header should have the link mentioned in the first header of the page ?

please correct me if I am wrong

ok, there are few limitations,
when you give a link to a section in sidebar eg

// _sidebar.md
* [chapter](./somelink.md)

when this link is clicked, few things happens

  • the ./somelink.md resolves with the router and your page request yourdocssite.com/#/somelink.md
  • docsify looks for the file name somelink.md and does the relative path resolving and makes a HTTP request using ajax for that file
  • it gets the content of the file (markdown), it then sends it to the markdown parser/renderer and then renders the HTML

now can you explain where you want the changes from these steps !

@Erimus-Koo
Copy link
Author

OK, let me clear. what I mean is the subMaxLevel, not the header in the _sidebar.md.

For a detail example:

// document.md

# Title1
## chapter1
...blablabla...

## chapter2
...blablabla...

## chapter3
...blablabla...

When the subMaxLevel works, the sidebar will display:

(maybe DOCUMENT here)
- Title1
    chapter1
    chapter2
    chapter3

And click chapter3, on the right frame, document.md open and scroll to the position of chapter3. This is the normal case.


Do some change, add a link:

// document.md

# Title1
## chapter1
...blablabla...

## chapter2
...blablabla...

## [chapter3](http://wiki.com/chapter3)
...blablabla...

When the subMaxLevel works, the sidebar will display:

(maybe DOCUMENT here)
- Title1
    chapter1
    chapter2
    chapter3 (a href has changed)

And click chapter3 now, it will open a new page with url "http://wiki.com/chapter3".

This is my point, I wish it works same as before. And click chapter3 in right frame, open the link.

Sidebar should always do navigate, in my expect.


And now, I modified it like

// document.md

# Title1
## chapter1
...blablabla...

## chapter2
...blablabla...

## chapter3 [link](http://wiki.com/chapter3)
...blablabla...

And in sidebar

(maybe DOCUMENT here)
- Title1
    chapter1
    chapter2
    chapter3 [link](http://wiki.com/chapter3)

as html, it is

<li>
    <a class="section-link" href="#/document?id=chapter3">chapter3 </a>
    <a href="http://wiki.com/chapter3" target="_blank" rel="noopener">link</a>
</li>

Then I use css to keep the a:first-child display, and hide others(the "link").


My native language is not English, so if some part is still not clear, tell me please.

@Koooooo-7
Copy link
Member

Currently, we render the subSideBar according to ur titles in markdown content. For example:
when u wrote them in xxx.md.

## [chapter](https://wikisource.com/chapter)
## part  [link](https://wikisource.com/chapter)

Firstly, the title was render to

<a href="https://wikisource.com/chapter" target="_blank">chapter</a>

and

<a href="https://wikisource.com/chapter" target="_blank">part<a href="https://wikisource.com/chapter" target="_blank">link</a></a>

(As for the 2nd one, the browser would correct the synax.)
so, that makes what u have seen.


Sidebar should always be a “navigation”, a guide to position in doc, not to outside.

I think it a good proposal. mightly, it wouldn't resolve it soon.
For current render logic , I think you need resolve those cases in ur way for now.

@anikethsaha
Copy link
Member

ok I see the issue!
seems fair !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants