@@ -171,29 +171,22 @@ function makeTeaser(body, terms) {
171 startIndex = word[2];
171 startIndex = word[2];
174− // add dark color around search terms
175− if (word[1] === TERM_WEIGHT) {
176− teaser.push("<span>");
178 startIndex = word[2] + word[0].length;
174 startIndex = word[2] + word[0].length;
179 teaser.push(body.substring(word[2], startIndex));
175 teaser.push(body.substring(word[2], startIndex));
181− if (word[1] === TERM_WEIGHT) {
182− teaser.push("</span>");
185 teaser.push("…");
178 teaser.push("…");
186 return teaser.join("");
179 return teaser.join("");
189−function formatSearchResultTitle(path) {
182+function formatSearchResultTitle(item) {
190− var pathArray = path.split( '/' );
183+ var pathArray = item.ref.split( '/' );
192 // first directory is in 4th element of split path array
185 // first directory is in 4th element of split path array
193 var firstPartTitle = pathArray[3];
186 var firstPartTitle = pathArray[3];
195 // last directory is in 2nd to last element of array
188 // last directory is in 2nd to last element of array
196− var lastPartTitle = pathArray[pathArray.length-2].replace(/-/g,' ');
189+ var lastPartTitle = item.doc.title;
198 var fullTitle = firstPartTitle + '<span class="gray90 inline-block pl2">' + ' / ' + lastPartTitle + '</span>';
191 var fullTitle = firstPartTitle + '<span class="gray90 inline-block pl2">' + ' / ' + lastPartTitle + '</span>';
@@ -201,10 +194,11 @@ function formatSearchResultTitle(path) {
203function formatSearchResultItem(item, terms) {
196function formatSearchResultItem(item, terms) {
204 var li = document.createElement("li");
198 var li = document.createElement("li");
205 var createA = document.createElement("a");
199 var createA = document.createElement("a");
206 li.appendChild(createA);
200 li.appendChild(createA);
207− var teaserTitle = formatSearchResultTitle(item.ref);
201+ var teaserTitle = formatSearchResultTitle(item);
208 li.classList.add("search-results__item");
202 li.classList.add("search-results__item");
209 li.classList.add("ph3");
203 li.classList.add("ph3");
210 var hrefA = item.ref;
204 var hrefA = item.ref;
@@ -297,7 +291,7 @@ function initSearch() {
299 currentTerm = term;
293 currentTerm = term;
300− searchResultsHeader.innerText = `${results.length} search results for '${term}':`;
294+ searchResultsHeader.innerText = `${results.length} search results for '${term}':`;
301 for (var i = 0; i < Math.min(results.length, MAX_ITEMS); i++) {
295 for (var i = 0; i < Math.min(results.length, MAX_ITEMS); i++) {
302 if (!results[i].doc.body) {
296 if (!results[i].doc.body) {
303 continue;
297 continue;