Skip to content

Commit

Permalink
provide fallback if cookies blocked; check results array length to de…
Browse files Browse the repository at this point in the history
…tect if no results
  • Loading branch information
Joseph Lowinske committed Mar 23, 2018
1 parent 9168457 commit c90eb87
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions search.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

var client = algoliasearch('BH4D9OD16A', '5a93998460e4910a8769500d325250cb');
var index = client.initIndex('cockroachlabs');
var currentVersion = getCookie('currentVersion');
var currentVersion = getCookie('currentVersion') || 'stable';

var searchConfig = {
query: QueryString.q,
Expand All @@ -43,7 +43,7 @@
index.search(searchConfig, function searchDone(err, data) {
var div = $('<div/>');

if (data.hits) {
if (data.hits.length) {
data.hits.forEach(function(hit) {
if (hit._highlightResult.content.value.length > 450) {
hit._highlightResult.content.value = hit._highlightResult.content.value.slice(0, 450) + '...'
Expand Down

0 comments on commit c90eb87

Please sign in to comment.