Skip to content

Visiting homepage doesn't set homepage link in sidebar to active #1131

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

Closed
1 task done
groenroos opened this issue Apr 22, 2020 · 4 comments · Fixed by #1174
Closed
1 task done

Visiting homepage doesn't set homepage link in sidebar to active #1131

groenroos opened this issue Apr 22, 2020 · 4 comments · Fixed by #1174
Labels
docs related to the documentation of docsify itself pr welcome question

Comments

@groenroos
Copy link

Bug Report

Steps to reproduce

  1. Include a link to the homepage (README.md or whatever's defined in the homepage setting) in the sidebar
  2. Visit the docs root.

What is current behaviour

  1. The sidebar link to the homepage does not have the active class to highlight it, and its submenu is not expanded.
  2. If the homepage link is clicked, #/README is appended to the URL, and then the active class is included.
    • The URL fragment is always README, even if the file is called something else.

What is the expected behaviour

  1. The sidebar link to the homepage should have the active class, and the submenu should be expanded.
  2. There should only be one canonical URL for the homepage (preferably one without a fragment in the URL)
    • The fragment should at least match the filename defined in homepage

Other relevant information

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

  • Your OS: macOS 10.15.4

  • Node.js version: 13.13.0

  • yarn version: 1.22.4

  • Browser version: Chrome 80.0.3987.149

  • Docsify version: 4.11.3

  • Docsify plugins: pagination, copy-code

Please create a reproducible sandbox

Edit angry-hodgkin-3vxu8

Mention the docsify version in which this bug was not present (if any)

N/A

@anikethsaha
Copy link
Member

anikethsaha commented Apr 22, 2020

try setting _sidebar.md to

- Sidebar

  - [Home](/)
  - [Another page](another.md)

/ is not same as home.md so I would suggest using / as it will automatically render your homepage and it will set the active links

PS: thanks for filling the template completely and creating the sandbox.
its very rare to see here.

@groenroos
Copy link
Author

That does seem to fix the problem, thanks! 🎉

I do think the weirdness around linking to the proper name of the homepage file is something that should be fixed though. Or at least if this is intended behaviour, maybe it could be documented more clearly?

@anikethsaha
Copy link
Member

this is an intended behavior as we do ajax request to the file based on the URL and we do supported remote file rendering and even remote homepage.
yes, I do think it should be documented.
Feel free to submit a PR for the docs change

@anikethsaha anikethsaha added docs related to the documentation of docsify itself pr welcome labels Apr 22, 2020
zhouzi added a commit to zhouzi/docsify that referenced this issue May 12, 2020
@zhouzi
Copy link
Contributor

zhouzi commented May 12, 2020

this is an intended behavior as we do ajax request to the file based on the URL and we do supported remote file rendering and even remote homepage.

Wouldn't it be possible to check for config.homepage if the file cannot be requested based on the URL? I mean, if the URL is /, obviously.

I opened a PR to update the documentation btw 🙂

anikethsaha added a commit that referenced this issue May 15, 2020
Fix #1131: Document homepage active link pitfall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs related to the documentation of docsify itself pr welcome question
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants