-
Notifications
You must be signed in to change notification settings - Fork 498
/
app.js
67 lines (59 loc) · 1.45 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
59
60
61
62
63
64
65
66
67
const {instantsearch} = window;
const search = instantsearch({
appId: 'latency',
apiKey: '3d9875e51fbd20c7754e65422f7ce5e1',
indexName: 'bestbuy',
urlSync: true,
});
search.addWidget(
instantsearch.widgets.hits({
container: '#hits',
templates: {
empty: 'No results',
item: '<div class="product-picture"><img src="{{{image}}}" /></div> ' +
'<div class="desc">{{{_highlightResult.name.value}}}</div>' +
'<div class="sale-price">$ {{{salePrice}}}</div>',
},
hitsPerPage: 8,
})
);
search.addWidget(
instantsearch.widgets.searchBox({
container: '#search-box',
placeholder: 'Search for products',
})
);
search.addWidget(
instantsearch.widgets.refinementList({
container: '#refinement-list',
attributeName: 'category',
templates: {
header: 'Refine by',
},
autoHideContainer: false,
})
);
search.addWidget(
instantsearch.widgets.currentRefinedValues({
container: '#current-refined-values',
// This widget can also contain a clear all link to remove all filters,
// we disable it in this example since we use `clearAll` widget on its own.
clearAll: false,
})
);
search.addWidget(
instantsearch.widgets.clearAll({
container: '#clear-all',
templates: {
link: 'Clear all filters',
},
})
);
search.addWidget(
instantsearch.widgets.pagination({
container: '#pagination',
maxPages: 10,
scrollTo: true,
})
);
search.start();