aboutsummaryrefslogtreecommitdiff
path: root/assets/search-data.js
blob: 684843870d879eecf7f026d345f8c5196b432454 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
(function() {
  const pages = [
    {{ range $index, $page := .Site.Pages }}
      {{- if $index -}},{{- end }}
      {
        'idx': {{ $index }},
        'href': '{{ $page.RelPermalink }}',
        'title': {{ (partial "docs/title" $page) | jsonify }},
        'content': {{ $page.Plain | jsonify }}
      }
    {{- end -}}
  ];

  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);
  })

  window.bookSearch = {
    pages: pages,
    index: index,
  }
})();