From 1f3addcca5bad9ed12ed3e1df7ba75859c650249 Mon Sep 17 00:00:00 2001 From: Alex Shpak Date: Tue, 16 Jul 2019 14:34:02 +0200 Subject: Implement search, loading on demand --- assets/search-data.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 assets/search-data.js (limited to 'assets/search-data.js') 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); + }), + } +})(); -- cgit v1.2.3