-
Notifications
You must be signed in to change notification settings - Fork 122
/
Copy pathapp.js
58 lines (52 loc) · 1.17 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* global instantsearch */
const algoliasearch = window['algoliasearch/lite'].liteClient;
const searchClient = algoliasearch(
'latency',
'6be0576ff61c053d5f9a3225e2a90f76'
);
const categoryMenu = instantsearch.widgets.panel({
templates: {
header: 'Category',
},
})(instantsearch.widgets.menu);
const brandList = instantsearch.widgets.panel({
templates: {
header: 'Brands',
},
})(instantsearch.widgets.refinementList);
const search = instantsearch({
indexName: 'instant_search',
searchClient,
routing: true,
insights: true,
});
search.addWidgets([
instantsearch.widgets.searchBox({
container: '#searchbox',
}),
instantsearch.widgets.clearRefinements({
container: '#clear-refinements',
}),
instantsearch.widgets.hits({
container: '#hits',
templates: {
item: `
<div>
{{#helpers.highlight}}{ "attribute": "name" }{{/helpers.highlight}}
</div>
`,
},
}),
categoryMenu({
container: '#menu',
attribute: 'categories',
}),
brandList({
container: '#refinement-list',
attribute: 'brand',
}),
instantsearch.widgets.pagination({
container: '#pagination',
}),
]);
search.start();