From f416a71bf8bb77e7af9ade9eea7fe3b662962290 Mon Sep 17 00:00:00 2001 From: Alex Shpak Date: Mon, 6 Jul 2020 22:17:36 +0200 Subject: #236, #171 Add section to search results --- assets/search-data.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'assets/search-data.js') diff --git a/assets/search-data.js b/assets/search-data.js index 859e6ad..f324281 100644 --- a/assets/search-data.js +++ b/assets/search-data.js @@ -1,6 +1,6 @@ 'use strict'; -(function() { +(function () { const indexCfg = {{ with i18n "bookSearchConfig" }} {{ . }}; {{ else }} @@ -10,18 +10,21 @@ indexCfg.doc = { id: 'id', field: ['title', 'content'], - store: ['title', 'href'], + store: ['title', 'href', 'section'], }; const index = FlexSearch.create('balance', indexCfg); window.bookSearchIndex = index; {{ range $index, $page := where .Site.Pages "Kind" "in" (slice "page" "section") }} + {{ if $page.Content }} 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 -}} + {{- end -}} })(); -- cgit v1.2.3