summaryrefslogtreecommitdiff
path: root/assets/search-data.js
diff options
context:
space:
mode:
authorAlex Shpak <alex-shpak@users.noreply.github.com>2019-07-16 14:34:02 +0200
committerAlex Shpak <alex-shpak@users.noreply.github.com>2019-08-06 11:33:42 +0200
commit1f3addcca5bad9ed12ed3e1df7ba75859c650249 (patch)
tree2e277c7fad1f89a4aafcafa89fc269e257540f09 /assets/search-data.js
parentdda0a0eab19457598b71f2b2b2f978b09d3f95c7 (diff)
Implement search, loading on demand
Diffstat (limited to 'assets/search-data.js')
-rw-r--r--assets/search-data.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/assets/search-data.js b/assets/search-data.js
new file mode 100644
index 0000000..5b015e4
--- /dev/null
+++ b/assets/search-data.js
@@ -0,0 +1,24 @@
+(function() {
+ const pages = [
+ {{ range $index, $page := .Site.Pages }}
+ {{- if and $index (gt $index 0) -}},{{- end }}
+ {
+ "idx": {{ $index }},
+ "href": "{{ $page.RelPermalink }}",
+ "title": "{{ partial "docs/title" $page }}",
+ "content": {{ $page.Plain | jsonify }}
+ }
+ {{- end -}}
+ ];
+
+ window.bookSearch = {
+ pages: pages,
+ idx: lunr(function() {
+ this.ref('idx');
+ this.field('title');
+ this.field('content');
+
+ pages.forEach(this.add, this);
+ }),
+ }
+})();