Change function results and relative locations of JavaScript files
This commit is contained in:
parent
0ee02bbe37
commit
0fe00bf114
|
@ -1,4 +1,4 @@
|
|||
// static/scripts/fixedsearch/fixedsearch.js
|
||||
// js/fixedsearch.js
|
||||
/*--------------------------------------------------------------
|
||||
fixedsearch — Super fast, client side search for Hugo.io with Fusejs.io
|
||||
based on https://gist.github.com/cmod/5410eae147e4318164258742dd053993
|
||||
|
@ -67,7 +67,7 @@ fixedsearch = function(){
|
|||
}
|
||||
|
||||
// Use Enter (13) to move to the first result
|
||||
if (e.keyCode == 13) {
|
||||
if (e.keyCode == 13) {
|
||||
if (results_available && document.activeElement == search_input) {
|
||||
e.preventDefault(); // stop form from being submitted
|
||||
first.focus();
|
||||
|
@ -75,7 +75,7 @@ fixedsearch = function(){
|
|||
}
|
||||
|
||||
// Use Backspace (8) to switch back to the search input
|
||||
if (e.keyCode == 8) {
|
||||
if (e.keyCode == 8) {
|
||||
if (document.activeElement != search_input) {
|
||||
e.preventDefault(); // stop browser from going back in history
|
||||
search_input.focus();
|
||||
|
@ -173,10 +173,10 @@ fixedsearch = function(){
|
|||
--------------------------------------------------------------*/
|
||||
function search_init() {
|
||||
if (first_run) {
|
||||
load_script(window.location.origin + '/scripts/fixedsearch/fuse.js').then(() => {
|
||||
load_script(window.location.origin + '/js/fuse.js').then(() => {
|
||||
search_input.value = ""; // reset default value
|
||||
first_run = false; // let's never do this again
|
||||
fetch_JSON(search_form.getAttribute('data-language-prefix') + '/index.json', function(data){
|
||||
fetch_JSON('/index.json', function(data){
|
||||
var options = { // fuse.js options; check fuse.js website for details
|
||||
shouldSort: true,
|
||||
location: 0,
|
||||
|
@ -187,9 +187,7 @@ fixedsearch = function(){
|
|||
'permalink',
|
||||
'title',
|
||||
'date',
|
||||
'summary',
|
||||
'section',
|
||||
'categories',
|
||||
'description',
|
||||
'tags'
|
||||
]
|
||||
};
|
||||
|
@ -223,9 +221,7 @@ fixedsearch = function(){
|
|||
`<li><a href="${results[item].item.permalink}" tabindex="0">
|
||||
<span class="title">${results[item].item.title}</span>
|
||||
<span class="date">${results[item].item.date}</span>
|
||||
<span class="summary">${results[item].item.summary}</span>
|
||||
<span class="section">${results[item].item.section}</span>
|
||||
<span class="categories">${results[item].item.categories.join(', ')}</span>
|
||||
<span class="description">${results[item].item.description}</span>
|
||||
<span class="tags">${results[item].item.tags.join(', ')}</span>
|
||||
</a></li>`;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue