Skip to content

Commit

Permalink
fix: search json
Browse files Browse the repository at this point in the history
Signed-off-by: Yvonnick Esnault <[email protected]>
  • Loading branch information
yesnault committed Aug 11, 2020
1 parent fa566fe commit 45b2c1d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
4 changes: 1 addition & 3 deletions docs/layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@
</script>
<script type="text/javascript" src="{{ "js/script.js" | relURL }}"></script>
<script type="text/javascript" src="{{ "js/lunr.min.js" | relURL}}"></script>
<script type="text/javascript">
var baseurl = "{{.Site.BaseURL}}";
<a id="indexJSON" href="{{ "./index.json" | relURL}}"></a>

</script>
<script type="text/javascript" src="{{ "js/auto-complete.js" | relURL}}"></script>
<script type="text/javascript" src="{{ "js/search.js" | relURL}}"></script>
<script type="text/javascript" src="{{ "js/asciinema-player.js" | relURL}}"></script>
9 changes: 1 addition & 8 deletions docs/static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ function endsWith(str, suffix) {

// Initialize lunrjs using our generated index file
function initLunr() {
if (!endsWith(baseurl,"/")){
baseurl = baseurl+'/'
};

// First retrieve the index file
$.getJSON(baseurl +"index.json")
$.getJSON($('#indexJSON').attr('href'))
.done(function(index) {
pagesIndex = index;
// Set up lunrjs by declaring the fields we use
Expand Down Expand Up @@ -74,9 +70,6 @@ $( document ).ready(function() {
item.context = text;

var pathItem = item.uri;
if (pathItem.startsWith(baseurl)) {
pathItem = pathItem.slice(baseurl.length);
}
if (endsWith(pathItem,"/")) {
pathItem = pathItem.substring(0, pathItem.length-1);
};
Expand Down

0 comments on commit 45b2c1d

Please sign in to comment.