[bug fix] publication search

fixed where the search index couldn't be found
This commit is contained in:
zzossig 2020-07-01 06:00:37 +09:00
parent 6229f7fe20
commit 6757d0f3b1
1 changed files with 9 additions and 2 deletions

View File

@ -571,13 +571,20 @@
var searchResultPosition = JSON.parse({{ $searchResultPosition | jsonify }}); var searchResultPosition = JSON.parse({{ $searchResultPosition | jsonify }});
{{ $sectionType := .Type }} {{ $sectionType := .Type }}
var sectionType = JSON.parse({{ $sectionType | jsonify }}); var sectionType = JSON.parse({{ $sectionType | jsonify }});
{{ $kind := .Kind }}
var kind = JSON.parse({{ $kind | jsonify }});
var fuse = null; var fuse = null;
if (enableSearch) { if (enableSearch) {
(function initFuse() { (function initFuse() {
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open('GET', baseurl + langprefix + "/index.json"); if (sectionType === "publication" && kind !== "page") {
xhr.open('GET', permalink + "index.json");
} else {
xhr.open('GET', baseurl + langprefix + "/index.json");
}
xhr.setRequestHeader('Content-Type', 'application/json; charset=utf-8'); xhr.setRequestHeader('Content-Type', 'application/json; charset=utf-8');
xhr.onload = function () { xhr.onload = function () {
if (xhr.status === 200) { if (xhr.status === 200) {