mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2025-06-29 12:10:31 +00:00
feat: extract search out of header + use baseurl to search json index + add a step to explain how to use lunr-hugo + update perfect-scrollbar
This commit is contained in:
parent
102b4cea8d
commit
4218d1a27d
9 changed files with 27 additions and 23 deletions
static/js
|
@ -3,7 +3,7 @@ var lunrIndex, pagesIndex;
|
|||
// Initialize lunrjs using our generated index file
|
||||
function initLunr() {
|
||||
// First retrieve the index file
|
||||
$.getJSON("/json/search.json")
|
||||
$.getJSON(baseurl + "/json/search.json")
|
||||
.done(function(index) {
|
||||
pagesIndex = index;
|
||||
// Set up lunrjs by declaring the fields we use
|
||||
|
@ -50,7 +50,7 @@ function search(query) {
|
|||
// Let's get started
|
||||
initLunr();
|
||||
$( document ).ready(function() {
|
||||
horsey($("#search-by").get(0), {
|
||||
var horseyList = horsey($("#search-by").get(0), {
|
||||
suggestions: function (value, done) {
|
||||
var query = $("#search-by").val();
|
||||
var results = search(query);
|
||||
|
@ -81,4 +81,5 @@ $( document ).ready(function() {
|
|||
},
|
||||
limit: 10
|
||||
});
|
||||
horseyList.refreshPosition();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue