Skip to content

Instantly share code, notes, and snippets.

@AntoinePlu
Last active February 5, 2017 12:12
Show Gist options
  • Save AntoinePlu/e103ac8c7af1b2a9e16fa6cbbc790628 to your computer and use it in GitHub Desktop.
Save AntoinePlu/e103ac8c7af1b2a9e16fa6cbbc790628 to your computer and use it in GitHub Desktop.
// Create my searchbox
search.addWidget(
instantsearch.widgets.searchBox({
container: '#search-box',
placeholder: 'Search...',
autofocus: true,
})
);
// Retrieve my results
const hitTemplate = document.getElementById('twitter').innerHTML;
search.addWidget(
instantsearch.widgets.hits({
container: '#hits',
hitsPerPage: 100,
templates: {
item: hitTemplate,
},
transformData: hit => {
hit.stars = [];
for (var i = 1; i <= 5; ++i) {
hit.stars.push(i <= hit.rating);
}
return hit;
},
})
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment