Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

Commit 4613f39

Browse files
committed
Better search content handling
1 parent 58bff6f commit 4613f39

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

_layouts/search.html

+11-6
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
<div id="pagination"></div>
2222
</div>
2323

24-
25-
2624
<link rel="stylesheet" href="https://cdn.jsdelivr.net/instantsearch.js/1/instantsearch.min.css">
2725
<script src="https://cdn.jsdelivr.net/instantsearch.js/1/instantsearch.min.js"></script>
2826

@@ -74,6 +72,7 @@
7472
var title_highlighted = item._highlightResult.title;
7573
var title_plain = item.title;
7674
var url = item.url;
75+
var content = '';
7776
// Check if we can show title, if not - at least show URL
7877
if (typeof title_highlighted !== 'undefined') {
7978
title = title_highlighted.value;
@@ -83,14 +82,19 @@
8382
title = url;
8483
}
8584

85+
// Check if we have the description of the hit
86+
if ( typeof item._highlightResult.content !== 'undefined' ) {
87+
content = item._highlightResult.content.value;
88+
}
89+
8690
//TODO: fix the baseurl on the entire site then remove this:
8791
if ( baseUrl == '/' ) {
8892
var link = '<a href="' + url + '">' + title +'</a>';
8993
} else {
9094
var link = '<a href="' + baseUrl + url + '">' + title +'</a>';
9195
}
9296

93-
return '<div class="hit"><h2 class="hit-name">'+ link + '</h2><div class="hit-url">'+ document.location.origin + url +'</div><div class="hit-content">'+ item._highlightResult.text.value + '</div></div>';
97+
return '<div class="hit"><h2 class="hit-name">'+ link + '</h2><div class="hit-url">'+ document.location.origin + url +'</div><div class="hit-content">' + content + '</div></div>';
9498
},
9599
empty: '<div id="no-results-message"><p>No results found.</p></div>',
96100
},
@@ -107,11 +111,12 @@
107111
search.addWidget(
108112
instantsearch.widgets.refinementList({
109113
container: '#tags',
110-
attributeName: 'tags',
114+
attributeName: 'functional_areas',
111115
operator: 'or',
112-
limit: 10,
116+
limit: 20,
117+
sortBy: ["name:asc"],
113118
templates: {
114-
header: 'Tags'
119+
header: 'Functional Areas'
115120
}
116121
})
117122
);

0 commit comments

Comments
 (0)