mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 07:47:54 +00:00
update js
highlightJS -> https://highlightjs.org/download/ => update with desired languages, default: https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.14.2/highlight.min.js modernizr -> https://modernizr.com/download/?csstransforms3d-domprefixes-prefixes-setclasses-shiv-testallprops-testprop-teststyles lunrJS -> https://cdnjs.cloudflare.com/ajax/libs/lunr.js/2.3.5/lunr.min.js clipboard -> https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js jquery -> https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js featherlight -> https://cdnjs.cloudflare.com/ajax/libs/featherlight/1.7.13/featherlight.min.js search.js -> updated for lunrJS 2.3.5 learn.js -> updated for clipboard
This commit is contained in:
parent
2463671e20
commit
c5033d3ee6
9 changed files with 44 additions and 34 deletions
4
static/js/clipboard.min.js
vendored
4
static/js/clipboard.min.js
vendored
File diff suppressed because one or more lines are too long
7
static/js/featherlight.min.js
vendored
7
static/js/featherlight.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -65,7 +65,7 @@ $(document).ready(function(){
|
|||
|
||||
jQuery(document).ready(function() {
|
||||
// Add link button for every
|
||||
var text, clip = new Clipboard('.anchor');
|
||||
var text, clip = new ClipboardJS('.anchor');
|
||||
$("h1~h2,h1~h3,h1~h4,h1~h5,h1~h6").append(function(index, html){
|
||||
var element = $(this);
|
||||
var url = encodeURI(document.location.origin + document.location.pathname);
|
||||
|
|
2
static/js/jquery-3.3.1.min.js
vendored
Normal file
2
static/js/jquery-3.3.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -181,7 +181,7 @@ jQuery(document).ready(function() {
|
|||
|
||||
if (text.length > 5) {
|
||||
if (!clipInit) {
|
||||
var text, clip = new Clipboard('.copy-to-clipboard', {
|
||||
var text, clip = new ClipboardJS('.copy-to-clipboard', {
|
||||
text: function(trigger) {
|
||||
text = $(trigger).prev('code').text();
|
||||
return text.replace(/^\$\s/gm, '');
|
||||
|
|
6
static/js/lunr.min.js
vendored
6
static/js/lunr.min.js
vendored
File diff suppressed because one or more lines are too long
3
static/js/modernizr.custom-3.6.0.js
Normal file
3
static/js/modernizr.custom-3.6.0.js
Normal file
File diff suppressed because one or more lines are too long
|
@ -13,30 +13,33 @@ function initLunr() {
|
|||
// First retrieve the index file
|
||||
$.getJSON(baseurl +"index.json")
|
||||
.done(function(index) {
|
||||
pagesIndex = index;
|
||||
pagesIndex = index;
|
||||
// Set up lunrjs by declaring the fields we use
|
||||
// Also provide their boost level for the ranking
|
||||
lunrIndex = new lunr.Index
|
||||
lunrIndex.ref("uri");
|
||||
lunrIndex.field('title', {
|
||||
boost: 15
|
||||
});
|
||||
lunrIndex.field('tags', {
|
||||
boost: 10
|
||||
});
|
||||
lunrIndex.field("content", {
|
||||
boost: 5
|
||||
});
|
||||
lunrIndex = lunr(function() {
|
||||
this.ref("uri");
|
||||
this.field('title', {
|
||||
boost: 15
|
||||
});
|
||||
this.field('tags', {
|
||||
boost: 10
|
||||
});
|
||||
this.field("content", {
|
||||
boost: 5
|
||||
});
|
||||
|
||||
// Feed lunr with each file and let lunr actually index them
|
||||
pagesIndex.forEach(function(page) {
|
||||
lunrIndex.add(page);
|
||||
});
|
||||
lunrIndex.pipeline.remove(lunrIndex.stemmer)
|
||||
this.pipeline.remove(lunr.stemmer);
|
||||
this.searchPipeline.remove(lunr.stemmer);
|
||||
|
||||
// Feed lunr with each file and let lunr actually index them
|
||||
pagesIndex.forEach(function(page) {
|
||||
this.add(page);
|
||||
}, this);
|
||||
})
|
||||
})
|
||||
.fail(function(jqxhr, textStatus, error) {
|
||||
var err = textStatus + ", " + error;
|
||||
console.error("Error getting Hugo index flie:", err);
|
||||
console.error("Error getting Hugo index file:", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -46,9 +49,9 @@ function initLunr() {
|
|||
* @param {String} query
|
||||
* @return {Array} results
|
||||
*/
|
||||
function search(query) {
|
||||
function search(queryTerm) {
|
||||
// Find the item in our index corresponding to the lunr one to have more info
|
||||
return lunrIndex.search(query).map(function(result) {
|
||||
return lunrIndex.search(queryTerm+"^100"+" "+queryTerm+"*^10"+" "+"*"+queryTerm+"^10"+" "+queryTerm+"~2^1").map(function(result) {
|
||||
return pagesIndex.filter(function(page) {
|
||||
return page.uri === result.ref;
|
||||
})[0];
|
||||
|
|
Loading…
Reference in a new issue