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

29 lines
683 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'],
2020-11-10 21:50:21 +00:00
store: ['title', 'href', 'parent'],
2020-01-12 14:33:02 +00:00
};
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 }},
2020-11-10 21:50:21 +00:00
'parent': {{ with $page.Parent }}{{ (partial "title" .) | jsonify }}{{ else }}''{{ end }},
2020-01-12 14:33:02 +00:00
'content': {{ $page.Plain | jsonify }}
});
{{- end -}}
})();