Skip to content

Commit

Permalink
fix: use baseurl in search.js
Browse files Browse the repository at this point in the history
  • Loading branch information
rhnvrm committed Jun 4, 2020
1 parent a617d7b commit c6eb2f3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 4 additions & 1 deletion layouts/_default/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -18,6 +18,9 @@ <h3>Matching pages</h3>
</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}">
Expand Down
2 changes: 1 addition & 1 deletion static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c6eb2f3

Please sign in to comment.