/* global instantsearch algoliasearch */ const search = instantsearch({ indexName: 'instant_search', searchClient: algoliasearch('latency', '6be0576ff61c053d5f9a3225e2a90f76'), }); search.addWidget( instantsearch.widgets.searchBox({ container: '#searchbox', placeholder: 'Search for products', }) ); /******** Clear refinements Start ******/ // 1. Create a render function const renderClearRefinements = (renderOptions, isFirstRender) => { const { hasRefinements, refine } = renderOptions; document.querySelector('#clear-refinements').innerHTML = ` `; const button = document.querySelector('#clear-result'); button.addEventListener('click', () => { refine(); }); }; const customClearRefinements = instantsearch.connectors.connectClearRefinements( renderClearRefinements ); search.addWidgets([ customClearRefinements({ container: document.querySelector('#clear-refinements'), }) ]); /******** Clear refinements End ******/ // Brand List const renderRefinementList = (renderOptions, isFirstRender) => { const { items, refine } = renderOptions; const container = document.querySelector('#brand-list'); container.innerHTML = `
${instantsearch.highlight({ attribute: 'description', hit: item }).substring(0,40)}
${item.price}