matcornic / hugo-theme-learn

Porting Grav Learn theme to Hugo
https://learn.netlify.com/en/
MIT License
1.6k stars 1.28k forks source link

Search with cyrillic characters broken #365

Open pgorod opened 4 years ago

pgorod commented 4 years ago

Hi! First of all let me start by once again thanking the ongoing work done on this excellent Hugo Theme. 🎉

I recently updated our site (Repo, Live), and made a bunch of changes:

With this change, I noticed that the search box stopped working, but only for the Cyrillic alphabet (our site includes a Russian language version).

For example, if you try (Сделки) or any other word you pick up from the site, it doesn't do any find-as-you-type search, though it highlights the word in yellow if it is already showing in the current page.

I note that with another word it behaves a bit differently: Уведомления opens the dropdown list after you press space in the end, but I'm not sure that lit is correct.

Can you please help me troubleshoot this? Any ideas? Thanks a lot.

pgorod commented 4 years ago

If there is no one available to look at this, can somebody please give me some pointers so I can try troubleshooting this myself? It is important to us, we have our live site broken.

For example, could this be a bug in the underlying search software? Is that a separate project we rely on? What is it? Maybe I should open an Issue with them instead.

Thanks.

matalo33 commented 4 years ago

I would need to go back and remind myself exactly how search works but here are some initial ideas:

Search is provided by search.js and lunr.js. it's all client side (naturally, as it's a static site). There was probably some MRs which upgraded the search JS recently, which may have caused unintentional breakages such as yours and were not noticed in testing.

When the site is built with hugo a file named index.json is built which is necessary for search to work. You should see this in your site root and also in the Network tab on DevTools

Does DevTools in your browser show any javascript errors in the console relating to the search?

pgorod commented 4 years ago

Thanks, that is actually quite useful! I didn't find any Javascript errors in console.

I downloaded my index.json and examined it. It is quite big (978Kb) with English content, but doesn't seem to have anything in Russian. We have quite a lot of Russian content, so that is strange.

Do you know "who" is responsible for generating index.json? Is it that [outputs] JSON mention in config.toml?

Hhmm maybe this commit https://github.com/salesagility/SuiteDocs/commit/fdce11cbc7f8bc456a193688a4b38fa9dc724607 broke it...? Not that I see why, I am just wondering if this could be it...

pgorod commented 4 years ago

Ah, sorry, let me correct myself. Actually if I am in the Russian area of the site, a different index.json loads, and it has all the Russian content in it: https://docs.suitecrm.com//ru/index.json

Still, no errors in console that look relevant...

EDIT: maybe this is missing... https://lunrjs.com/guides/language_support.html https://github.com/MihaiValentin/lunr-languages

l-konov commented 4 years ago

We add this code to hugoroot/static/js and Russian search works correctly. Based on https://github.com/MihaiValentin/lunr-languages js.zip

And this file should be added to hugoroot/layouts/partials search.zip

likhobory commented 4 years ago

@pgorod @matalo33 @l-konov Confirmed, it works as expected.