hugo-geekdoc/assets/js/search-data.js

28 lines
578 B
JavaScript
Raw Normal View History

2020-01-12 14:33:02 +00:00
'use strict';
(function() {
const indexCfg = {{ with .Scratch.Get "geekdocSearchConfig" }}
{{ . | jsonify}};
{{ else }}
{};
{{ end }}
indexCfg.doc = {
id: 'id',
field: ['title', 'content'],
store: ['title', 'href'],
};
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 }},
'content': {{ $page.Plain | jsonify }}
});
{{- end -}}
})();