meteor / meteor-theme-hexo

The framework we use for docs.
https://docs-docs.netlify.com/docs/docs/
MIT License
64 stars 26 forks source link

Update calculation of sidebar scroll for non-root urls #52

Closed evans closed 6 years ago

evans commented 6 years ago

For doc sites such as Apollo Link, the sidebar scroll hides the searchbox, since the location.pathname is /docs/link/ rather than /. The new calculation also works on the meteor docs, at least in the console 😜.

document.querySelectorAll('.item-toc a.sidebar-link')[0] === document.querySelector('.item-toc a[href=""]') for your convenience

abernix commented 6 years ago

Thank you for looking at this, @evans! I think this does partially solve some instances of this problem, however even with this change, it appears that the search is still off the page when arriving to a sub-section anchor link, as seen in this Netlify preview of this PR (which I believe is working properly — you're the first PR to really test this implementation though!):

https://deploy-preview-52--theme-example.netlify.com/apollo-hexo-config/syntax-highlighting.html#Bash

It's possible that in order to accomplish this we might need to anchor the title and the search box and have the scrollable <div ... > content below them. Thoughts?

To clarify, I'm suggesting that this should be pinned:

image

evans commented 6 years ago

@abernix That makes total sense to pin it to the top of the sidebar. I'll try to take a look at it and see if my knowledge of html is proficient 💪