Skip to content

Commit

Permalink
docs(examples): use getAlgoliaHits before returning sources
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour committed Sep 10, 2020
1 parent b178487 commit 523f015
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions examples/js/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,35 @@ autocomplete<QuerySuggestionHit>({
container: '#autocomplete',
debug: true,
// dropdownPlacement: 'start',
getSources() {
return [
{
getInputValue: ({ suggestion }) => suggestion.query,
getSuggestions({ query }) {
return getAlgoliaHits({
searchClient,
queries: [
{
indexName: 'instant_search_demo_query_suggestions',
query,
params: {
hitsPerPage: 4,
},
},
],
});
getSources({ query }) {
return getAlgoliaHits({
searchClient,
queries: [
{
indexName: 'instant_search_demo_query_suggestions',
query,
params: {
hitsPerPage: 4,
},
},
templates: {
item({ item }) {
return reverseHighlightItem<QuerySuggestionHit>({
item,
attribute: 'query',
});
],
}).then((hits) => {
return [
{
getInputValue: ({ suggestion }) => suggestion.query,
getSuggestions() {
return hits;
},
templates: {
item({ item }) {
return reverseHighlightItem<QuerySuggestionHit>({
item,
attribute: 'query',
});
},
},
},
},
];
];
});
},
});

0 comments on commit 523f015

Please sign in to comment.