mirror of
https://github.com/alex-shpak/hugo-book.git
synced 2024-11-25 04:43:04 +00:00
28 lines
578 B
JavaScript
28 lines
578 B
JavaScript
'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 := .Site.RegularPages }}
|
|
index.add({
|
|
'id': {{ $index }},
|
|
'href': '{{ $page.RelPermalink }}',
|
|
'title': {{ (partial "docs/title" $page) | jsonify }},
|
|
'content': {{ $page.Plain | jsonify }}
|
|
});
|
|
{{- end -}}
|
|
})();
|