ozobi 2019-02-07 14:45:13 +01:00 committed by Matthew Taylor
parent 2463671e20
commit c5033d3ee6
9 changed files with 44 additions and 34 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -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

File diff suppressed because one or more lines are too long

View file

@ -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, '');

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -16,27 +16,30 @@ function initLunr() {
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', {
lunrIndex = lunr(function() {
this.ref("uri");
this.field('title', {
boost: 15
});
lunrIndex.field('tags', {
this.field('tags', {
boost: 10
});
lunrIndex.field("content", {
this.field("content", {
boost: 5
});
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) {
lunrIndex.add(page);
});
lunrIndex.pipeline.remove(lunrIndex.stemmer)
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];