Replies: 4 comments 4 replies
-
The utilities underlying to Algolia's highlight components are available here: https://github.com/algolia/autocomplete/tree/next/packages/autocomplete-preset-algolia/src/highlight and should work if you delineate your object as |
Beta Was this translation helpful? Give feedback.
-
Thank you for your quick answer. Not being very advanced - do I interpret your answer correctly when I deduct that the below code should display highlighted results?
|
Beta Was this translation helpful? Give feedback.
-
It does not contain HTML - it's just a method (the attribute of the object to display). So this correctly displays the list of items (without highlighting anything, of course).
|
Beta Was this translation helpful? Give feedback.
-
Sorry for being somewhat vague earlier @john-999, but here's an example with non-algolia highlighting: https://codesandbox.io/s/blissful-fog-rnhxsm?file=/app.js
const items = [{ some_attribute: 'includes <mark>highlighting html</mark>' }];
return items.map((item) => ({
item,
_highlightResult: {
some_attribute: {
value: item.some_attribute
.replace(/<mark>/g, HIGHLIGHT_PRE_TAG)
.replace(/<\/mark>/g, HIGHLIGHT_POST_TAG),
},
},
}));
item({item, components }) {
return components.Highlight({hit: item, attribute: 'some_attribute' })
} |
Beta Was this translation helpful? Give feedback.
-
Hey guys,
what if one of the "Sources" we define in an autocomplete search box needs to use our own Ajax calls (like we used to do it with Twitter typeahead), instead of the Algolia service?
Does this autocomplete currently have a highlighting option/solution I'm not aware of?
If not, any plans to add this option again? If yes, when?
(And also: What about the "reverse-highlighting" option in this context?)
Beta Was this translation helpful? Give feedback.
All reactions