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
|
---
version: 2
---
const search = instantsearch({
indexName: 'gitlab',
searchClient: algoliasearch('BH4D9OD16A', 'ce1690e1421303458a1fcbea0cc4a927'),
algoliaOptions: {
// Filter by tags as described in https://github.com/algolia/docsearch-configs/blob/master/configs/gitlab.json
'filters': "tags:gitlab<score=3> OR tags:omnibus<score=2> OR tags:runner<score=1>",
},
routing: {
stateMapping: instantsearch.stateMappings.singleIndexQ('gitlab')
},
searchFunction: function(helper) {
var searchResults = $('.search-results');
if (helper.state.query === '') {
searchResults.hide();
return;
}
helper.search();
searchResults.show();
}
});
search.addWidgets([
instantsearch.widgets.searchBox({
container: '#searchbox',
placeholder: 'Search GitLab Documentation',
showReset: true,
showLoadingIndicator: true
}),
instantsearch.widgets.poweredBy({
container: '#powered-by',
}),
instantsearch.widgets.refinementList({
container: '#refinement-list',
attribute: 'tags',
sortBy: ["name:asc","isRefined"],
templates: {
header: 'Refine your search:'
}
}),
instantsearch.widgets.infiniteHits({
container: '#hits',
templates: {
item: document.getElementById('hit-template').innerHTML,
empty: "We didn't find any results for the search <em>\"{{query}}\"</em>"
},
escapeHits: true,
showMoreLabel: "Load more results..."
}),
instantsearch.widgets.stats({
container: '#stats'
}),
instantsearch.widgets.configure({
// Number of results shown in the search dropdown
'hitsPerPage': 10,
})
]);
search.start();
|