diff options
author | Rohan Verma <hello@rohanverma.net> | 2020-06-05 01:21:35 +0300 |
---|---|---|
committer | Rohan Verma <hello@rohanverma.net> | 2020-06-05 01:21:35 +0300 |
commit | c6eb2f3f5236e25df8ff8acb8e9fca927e8dd7fd (patch) | |
tree | 470ceda53ee51dd749e182197f7914bb9efceea1 | |
parent | a617d7b33ae9df6f139dbeebb55bccb1f4f29c18 (diff) |
fix: use baseurl in search.js
-rw-r--r-- | exampleSite/config.toml | 2 | ||||
-rw-r--r-- | layouts/_default/search.html | 5 | ||||
-rw-r--r-- | static/js/search.js | 2 |
3 files changed, 6 insertions, 3 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml index af0c174..57ba7ab 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -9,7 +9,7 @@ theme = "bodhi" author = "Rohan Verma" commentoSrc = "https://commento.example.com/js/commento.js" footerMessage = "Keep it simple." - disableSearch = true + disableSearch = false [[menu.main]] name = "home" diff --git a/layouts/_default/search.html b/layouts/_default/search.html index 914ff3d..4a69a11 100644 --- a/layouts/_default/search.html +++ b/layouts/_default/search.html @@ -2,7 +2,7 @@ <script src="{{ "/js/jquery-3.3.1.min.js" | relURL }}"></script> <script src="{{ "/js/fuse.min.js" | relURL }}"></script> <script src="{{ "/js/jquery.mark.min.js" | relURL }}"></script> -<script src="{{ "js/search.js" | relURL }}"></script> +<script src="{{ "/js/search.js" | relURL }}"></script> {{ end }} {{ define "main" }} <div> @@ -18,6 +18,9 @@ </div> </div> </div> +<script> +var baseURL = {{ .Site.BaseURL }} +</script> <!-- this template is sucked in by search.js and appended to the search-results div above. So editing here will adjust style --> <script id="search-result-template" type="text/x-js-template"> <div id="summary-${key}"> diff --git a/static/js/search.js b/static/js/search.js index 4daa43e..b30bcc5 100644 --- a/static/js/search.js +++ b/static/js/search.js @@ -28,7 +28,7 @@ if(searchQuery){ function executeSearch(searchQuery){ - $.getJSON( "/index.json", function( data ) { + $.getJSON( baseURL + "index.json", function( data ) { var pages = data; var fuse = new Fuse(pages, fuseOptions); var result = fuse.search(searchQuery); |