hugo-book-theme/assets/search-data.js

26 lines
557 B
JavaScript
Raw Permalink Normal View History

2019-10-27 11:58:58 +01:00
'use strict';
2019-07-16 14:34:02 +02:00
(function() {
2019-10-27 11:58:58 +01:00
const indexCfg = {{ with .Site.Params.BookSearchConfig }}
{{ . }}
{{ end }};
2019-07-16 14:34:02 +02:00
2019-10-27 11:58:58 +01:00
indexCfg.doc = {
id: 'id',
field: ['title', 'content'],
store: ['title', 'href'],
};
2019-10-20 19:02:32 +02:00
2019-10-27 11:58:58 +01:00
const index = FlexSearch.create('balance', indexCfg);
window.bookSearchIndex = index;
2019-10-20 19:02:32 +02:00
2019-10-27 11:58:58 +01:00
{{ range $index, $page := .Site.Pages }}
index.add({
'id': {{ $index }},
'href': '{{ $page.RelPermalink }}',
'title': {{ (partial "docs/title" $page) | jsonify }},
'content': {{ $page.Plain | jsonify }}
});
{{- end -}}
2019-07-16 14:34:02 +02:00
})();