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

31 lines
658 B
JavaScript
Raw Normal View History

2019-07-16 14:34:02 +02:00
(function() {
const pages = [
{{ range $index, $page := .Site.Pages }}
2019-08-08 13:15:19 +02:00
{{- if $index -}},{{- end }}
2019-07-16 14:34:02 +02:00
{
2019-10-20 19:02:32 +02:00
'idx': {{ $index }},
'href': '{{ $page.RelPermalink }}',
'title': {{ (partial "docs/title" $page) | jsonify }},
'content': {{ $page.Plain | jsonify }}
2019-07-16 14:34:02 +02:00
}
{{- end -}}
];
2019-10-20 19:02:32 +02:00
var index = new FlexSearch({
cache: true,
encode: 'balance',
/* tokenize: function(str) {
return str.replace(/[\x00-\x7F]/g, ' ').split('');
} */
});
pages.forEach(function(page, x) {
index.add(x, pages[x].content);
})
2019-07-16 14:34:02 +02:00
window.bookSearch = {
pages: pages,
2019-10-20 19:02:32 +02:00
index: index,
2019-07-16 14:34:02 +02:00
}
})();