hugo-geekdoc/assets/js/search-data.js
2020-11-10 22:50:21 +01:00

29 lines
683 B
JavaScript

'use strict';
(function() {
const indexCfg = {{ with .Scratch.Get "geekdocSearchConfig" }}
{{ . | jsonify}};
{{ else }}
{};
{{ end }}
indexCfg.doc = {
id: 'id',
field: ['title', 'content'],
store: ['title', 'href', 'parent'],
};
const index = FlexSearch.create(indexCfg);
window.geekdocSearchIndex = index;
{{ range $index, $page := .Site.Pages }}
index.add({
'id': {{ $index }},
'href': '{{ $page.RelPermalink }}',
'title': {{ (partial "title" $page) | jsonify }},
'parent': {{ with $page.Parent }}{{ (partial "title" .) | jsonify }}{{ else }}''{{ end }},
'content': {{ $page.Plain | jsonify }}
});
{{- end -}}
})();