With InstantSearch, you can leverage the item template. This template receives an object containing a single record. On the hit object you can access the _highlightResult
and _snippetResult
instantsearch.widgets.hits({
container: '#hits',
templates: {
item(hit) {
return `<article>
<b>Highlight Arrays</b>
<ul>${hit._highlightResult.categories
.map(({ value }) => `<li>${value}</li>`)
.join('')}</ul>
<b>Snippet Arrays</b>
<ul>${hit._snippetResult.categories
.map(({ value }) => `<li>${value}</li>`)
.join('')}</ul>
</article>`;
},
},
}),