This repository has been archived by the owner on Sep 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
/
search2.html
70 lines (61 loc) · 1.78 KB
/
search2.html
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
68
69
70
---
layout: default
title: Search
---
<link rel="stylesheet" type="text/css" href="/assets/css/instantsearch.min.css">
<link rel="stylesheet" type="text/css" href="/assets/css/instantsearch-theme-algolia.min.css">
<script src="/assets/js/instantsearch.js"></script>
<div id="ais-input-container"></div>
<div id="ais-results-container"></div>
<div id="ais-pagination-container"></div>
{% raw %}
<script>
var search = instantsearch({
appId: 'BH4D9OD16A',
apiKey: '8e0152321e991cc72635d18bfd059bf1',
indexName: 'bazel',
urlSync: true,
searchParameters: {
hitsPerPage: 10
}
});
search.addWidget(
instantsearch.widgets.searchBox({
container: '#ais-input-container',
placeholder: 'Search in the documentation',
autofocus: false,
poweredBy: true
})
);
var template = `<div class="ais-result">
<div class="ais-lvl1">
{{#hierarchy.lvl1}} {{{_highlightResult.hierarchy.lvl1.value}}} {{/hierarchy.lvl1}}
</div>
<span class="ais-lvl2">
<a href="{{url}}">{{#hierarchy.lvl2}}{{{_highlightResult.hierarchy.lvl2.value}}}{{/hierarchy.lvl2}}</a>
</span>
{{#hierarchy.lvl3}} - {{{_highlightResult.hierarchy.lvl3.value}}} {{/hierarchy.lvl3}}
<div class="ais-url">{{url}}</div>
<div class="ais-content">
{{{#content}}} {{{_highlightResult.content.value}}} {{{/content}}}
</div>
</div>`;
search.addWidget(
instantsearch.widgets.hits({
container: '#ais-results-container',
templates: {
empty: 'No results',
item: template,
}
})
);
search.addWidget(
instantsearch.widgets.pagination({
container: '#ais-pagination-container',
maxPages: 15,
scrollTo: false
})
);
search.start();
</script>
{% endraw %}