blob: 859e6adade2670c56df3367d4c31b54e671b2650 (
plain)
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
|
'use strict';
(function() {
const indexCfg = {{ with i18n "bookSearchConfig" }}
{{ . }};
{{ else }}
{};
{{ end }}
indexCfg.doc = {
id: 'id',
field: ['title', 'content'],
store: ['title', 'href'],
};
const index = FlexSearch.create('balance', indexCfg);
window.bookSearchIndex = index;
{{ range $index, $page := where .Site.Pages "Kind" "in" (slice "page" "section") }}
index.add({
'id': {{ $index }},
'href': '{{ $page.RelPermalink }}',
'title': {{ (partial "docs/title" $page) | jsonify }},
'content': {{ $page.Plain | jsonify }}
});
{{- end -}}
})();
|