diff options
author | zzossig <zzossig@gmail.com> | 2020-06-11 07:40:36 +0300 |
---|---|---|
committer | zzossig <zzossig@gmail.com> | 2020-06-11 07:40:36 +0300 |
commit | f321503b94fafa405666acfec7c574ae50c60323 (patch) | |
tree | afdf91e88fc1bb750629f7b8f900ffd079d84d59 /layouts | |
parent | 0a2baf0d55007fa33cc16d1420d8216412f65edc (diff) |
[bug fix] heavy search index
fix #251 #252
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/_default/single.searchindex.json | 8 | ||||
-rw-r--r-- | layouts/partials/head/scripts.html | 6 |
2 files changed, 4 insertions, 10 deletions
diff --git a/layouts/_default/single.searchindex.json b/layouts/_default/single.searchindex.json deleted file mode 100644 index 11e8280..0000000 --- a/layouts/_default/single.searchindex.json +++ /dev/null @@ -1,8 +0,0 @@ -{{ .Scratch.Delete "searchindex" }}
-{{- $.Scratch.Add "searchindex" slice -}}
-{{- range $index, $element := (where .Site.RegularPages "Kind" "page") -}}
- {{ with $element.Plain }}
- {{- $.Scratch.Add "searchindex" (dict "id" $index "title" $element.Title "uri" $element.Permalink "tags" $element.Params.tags "section" $element.Section "content" $element.Plain "description" $element.Description) -}}
- {{ end }}
-{{- end -}}
-{{- $.Scratch.Get "searchindex" | jsonify -}}
\ No newline at end of file diff --git a/layouts/partials/head/scripts.html b/layouts/partials/head/scripts.html index e60a679..42751e4 100644 --- a/layouts/partials/head/scripts.html +++ b/layouts/partials/head/scripts.html @@ -550,6 +550,8 @@ // ========================== search ========================== + {{ $baseurl:= $.Site.BaseURL }} + var baseurl = JSON.parse({{ $baseurl | jsonify }}); {{ $permalink:= .Permalink }} var permalink = JSON.parse({{ $permalink | jsonify }}); var searchResults = null; @@ -564,10 +566,10 @@ var sectionType = JSON.parse({{ $sectionType | jsonify }}); var fuse = null; - + (function initFuse() { var xhr = new XMLHttpRequest(); - xhr.open('GET', permalink + "index.json"); + xhr.open('GET', baseurl + "/index.json"); xhr.setRequestHeader('Content-Type', 'application/json; charset=utf-8'); xhr.onload = function () { if (xhr.status === 200) { |