diff --git a/assets/js/search.js b/assets/js/search.js index cbc42bdc..89a0b442 100644 --- a/assets/js/search.js +++ b/assets/js/search.js @@ -104,9 +104,7 @@ function fetchJSON(path, callback) { } function buildIndex() { - var baseURL = document - .querySelector('script[data-id="fusejs"][data-url]') - .getAttribute("data-url"); + var baseURL = wrapper.getAttribute("data-url"); fetchJSON(baseURL + "index.json", function (data) { var options = { shouldSort: true, diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 6d1eee96..da96fede 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -56,6 +56,11 @@ {{ $jsDark := resources.Get "js/dark.js" }} {{ $assets.Add "js" (slice $jsDark) }} {{ end }} + {{ if .Site.Params.enableSearch | default false }} + {{ $jsFuse := resources.Get "lib/fuse/fuse.min.js" }} + {{ $jsSearch := resources.Get "js/search.js" }} + {{ $assets.Add "js" (slice $jsFuse $jsSearch) }} + {{ end }} {{ if $assets.Get "js" }} {{ $bundleJS := $assets.Get "js" | resources.Concat "js/main.bundle.js" | resources.Minify | resources.Fingerprint "sha512" }} diff --git a/layouts/partials/search.html b/layouts/partials/search.html index 9a59c49e..0a1eb06d 100644 --- a/layouts/partials/search.html +++ b/layouts/partials/search.html @@ -1,12 +1,7 @@ -{{ $fuseLib := resources.Get "lib/fuse/fuse.min.js" }} -{{ $fuseConfig := resources.Get "js/search.js" }} -{{ $fuseConfig := $fuseConfig | resources.Minify }} -{{ $fuseJS := slice $fuseLib $fuseConfig | resources.Concat "js/fuse.bundle.js" | resources.Fingerprint "sha512" -}} - -