Offline search with Lunr.js#142
Offline search with Lunr.js#142LisaFC merged 8 commits intogoogle:masterfrom theletterf:offline-search-lunr
Conversation
|
@LisaFC: Not sure why the checks are failing. :-/ |
|
Ooh, thanks for that. I'll see if I can figure out why the checks are failing. |
|
Ok, looks like it was some Netlify weirdosity, I manually reran the deploy and it now works fine! Will take a proper look at the change now. |
LisaFC
left a comment
There was a problem hiding this comment.
This is great! Once this is in I can add a search-index.md to the example site so it'll actually work if users enable it.
|
@LisaFC: all resolved. Only two issues remain:
|
Fantastic!
Answered there, but just to reiterate: "Aaaaaah, right, I see what's going on. So as you've written it here, it means that the top search field only displays if the sidebar search is disabled (which is what you want for local search and Algolia), but they actually both work fine displayed at the same time if you're using a Google custom search (as you can see on docsy.dev) because it doesn't have an instant results feature. At the moment for Algolia search we just tell people to disable the sidebar search as it doesn't currently work with Algolia, I think for now we can just do the same for local search. I'll have a think for a future iteration whether we can make the sidebar search automatically disappear if you're using anything except Google custom search."
We should add it to the user guide and example sites (so for the user guide in this repo, add userguide/content/en/search-index.md) |
|
@LisaFC Done - and PR opened for search-index.md in the demo site repository: google/docsy-example#33 |
|
Brilliant, thanks so much for doing this, I think the Docsy community will find this super useful! |
|
Sweet! Thanks!! |
Hi there!
As mentioned in #45, I added offline search with Lunr.js, borrowing heavily from existing tutorials.
How to enable offline search
offlineSearch = trueto the mainconfig.tomlfile.homein the mainconfig.tomlfile:That's it. Upon build, pages will be indexed into an
index.jsonfile by Lunr.js. The whole process is invoked bystatic/js/offline-search.js, which also handles instant results (thanks @mwalters!).Styling for the offline search field lives in
/static/css/offline-search.css.Current limitation: I didn't implement a search results page, but it can be done.