mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-12 20:15:25 +00:00
feat(search): show talk and publication abstracts in results
Instead of their page bodies which are often empty. Close #1253
This commit is contained in:
1 parent
55106c1ff6
commit
eacadc7935
1 file changed
+11
-4
@@ -84,10 +84,18 @@ function searchAcademic(query, fuse) {
|
||||
// Parse search results.
|
||||
function parseResults(query, results) {
|
||||
$.each( results, function(key, value) {
|
||||
let content = value.item.content;
|
||||
let content_key = value.item.section;
|
||||
let content = "";
|
||||
let snippet = "";
|
||||
let snippetHighlights = [];
|
||||
|
||||
// Show abstract in results for content types where the abstract is often the primary content.
|
||||
if (["publication", "talk"].includes(content_key)) {
|
||||
content = value.item.summary;
|
||||
} else {
|
||||
content = value.item.content;
|
||||
}
|
||||
|
||||
if ( fuseOptions.tokenize ) {
|
||||
snippetHighlights.push(query);
|
||||
} else {
|
||||
@@ -102,14 +110,13 @@ function parseResults(query, results) {
|
||||
}
|
||||
|
||||
if (snippet.length < 1) {
|
||||
snippet += content.substring(0, summaryLength*2);
|
||||
snippet += value.item.summary; // Alternative fallback: `content.substring(0, summaryLength*2);`
|
||||
}
|
||||
|
||||
// Load template.
|
||||
var template = $('#search-hit-fuse-template').html();
|
||||
let template = $('#search-hit-fuse-template').html();
|
||||
|
||||
// Localize content types.
|
||||
let content_key = value.item.section;
|
||||
if (content_key in content_type) {
|
||||
content_key = content_type[content_key];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user