Fragment size setting

This commit is contained in:
2020-06-09 21:40:53 -04:00
parent 8c1c1697e0
commit a011b7e97b
9 changed files with 36 additions and 22 deletions

View File

@@ -27,18 +27,12 @@ function gifOver(thumbnail, hit) {
}
function getContentHighlight(hit) {
const re = RegExp(/<mark>/g);
const sortByMathCount = (a, b) => {
return b.match(re).length - a.match(re).length;
};
if (hit.hasOwnProperty("highlight")) {
if (hit["highlight"].hasOwnProperty("content")) {
return hit["highlight"]["content"].sort(sortByMathCount)[0];
return hit["highlight"]["content"][0];
} else if (hit["highlight"].hasOwnProperty("content.nGram")) {
return hit["highlight"]["content.nGram"].sort(sortByMathCount)[0];
return hit["highlight"]["content.nGram"][0];
}
}