18F / jekyll_pages_api_search

DEPRECATED - Jekyll search plugin based on lunr.js and jekyll_pages_api
https://rubygems.org/gems/jekyll_pages_api_search
Other
39 stars 8 forks source link

Remove existing return call when search returns no results. #44

Closed eddietejeda closed 6 years ago

eddietejeda commented 6 years ago

Problem: The 18F website now shows a loading bar when results are loading. Using the renderJekyllPagesApiSearchResults hook, I am able to hide the loading bar when results are loaded. But I noticed that method that calls renderJekyllPagesApiSearchResults is guarded by a check to see if results == 0, it then returns from the method. See: https://github.com/18F/jekyll_pages_api_search/blob/master/assets/js/search-ui.js#L57

Solution: Removing that return will allow execution to continue to renderJekyllPagesApiSearchResults and will allow for custom render functions to handle rendering when showing no results. It also works with default method.

For additional safety, we make sure to return array just in case SearchResults.results is not already an array.

This approach is being used on the 18F website and this pull request solves our problem. More info here: https://github.com/18F/18f.gsa.gov/blob/add-loading-bar-to-search/assets/js/jekyll-pages-api-search.js#L10

afeld commented 6 years ago

Released as v0.4.5.