mirror of
https://github.com/miguelmota/cointop
synced 2024-11-18 15:25:31 +00:00
33 lines
857 B
JavaScript
33 lines
857 B
JavaScript
|
'use strict';
|
||
|
|
||
|
(function () {
|
||
|
const indexCfg = {{ with i18n "bookSearchConfig" }}
|
||
|
{{ . }};
|
||
|
{{ else }}
|
||
|
{};
|
||
|
{{ end }}
|
||
|
|
||
|
indexCfg.doc = {
|
||
|
id: 'id',
|
||
|
field: ['title', 'content'],
|
||
|
store: ['title', 'href', 'section'],
|
||
|
};
|
||
|
|
||
|
const index = FlexSearch.create('balance', indexCfg);
|
||
|
window.bookSearchIndex = index;
|
||
|
|
||
|
{{- $pages := where .Site.Pages "Kind" "in" (slice "page" "section") -}}
|
||
|
{{- $pages = where $pages "Params.booksearchexclude" "!=" true -}}
|
||
|
{{- $pages = where $pages "Content" "not in" (slice nil "") -}}
|
||
|
|
||
|
{{ range $index, $page := $pages }}
|
||
|
index.add({
|
||
|
'id': {{ $index }},
|
||
|
'href': '{{ $page.RelPermalink }}',
|
||
|
'title': {{ (partial "docs/title" $page) | jsonify }},
|
||
|
'section': {{ (partial "docs/title" $page.Parent) | jsonify }},
|
||
|
'content': {{ $page.Plain | jsonify }}
|
||
|
});
|
||
|
{{- end -}}
|
||
|
})();
|