cmfcmf / docusaurus-search-local

Offline / Local Search for Docusaurus v2. Try it live at:
https://cmfcmf.github.io/OpenWeatherMap-PHP-API/
MIT License
438 stars 67 forks source link

Search results don't navigate to the appropriate heading. #27

Closed shalvah closed 3 years ago

shalvah commented 3 years ago

Bug description

I search for a term. The search result shows me the appropriate page and heading containing that term. image

However, when I click on the result, I'm taken to the top of that page. Doesn't navigate to the header.

Reproduction

Build index, serve site, follow these steps

Environment

Package Versions

Docusaurus @2.0.0-alpha.70 @cmfcmf/docusaurus-search-local@0.5.0

Node Version

14.8.0

Docusaurus Environment

Default theme; default plugin settings

I'm thinking this should be a straightforward problem to solve?🤔 Retrieve the subheading and attach it as a URL fragment when navigating. I'd send in a PR for this, but I'm still finding my way around, so if anyone can point me to the appropriate parts of the codebase, that would be cool.

shalvah commented 3 years ago

Welp, just tried it on a fresh project and it worked this time... Not sure the cause of this🤔

cmfcmf commented 3 years ago

Hmm, I can't reproduce this at https://christianflach.de/OpenWeatherMap-PHP-API. Searching for code and clicking on a result leads to the following URL: https://christianflach.de/OpenWeatherMap-PHP-API/docs/apis/weather-forecast?highlight=code#by-zip-code

As you can see, the URL contains both the highlight for code and the id of the corresponding heading (by-zip-code). How does the link look like when it does not work? Does it contain a hash with the id of the heading?

shalvah commented 3 years ago

When it doesn't work, there isn't a hash.

I think I'll close this for now. It will likely be difficult to reproduce, because I think it was related to some other weird behaviour on my site (syntax highlighting stopped working too). Copied my content to a fresh Docusaurus installation with the same config and both features work.