Skip to content

Commit 1a787e7

Browse files
author
ZoeLeBlanc
committed
fixed search rendering issue
1 parent 0ffc926 commit 1a787e7

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

en/lessons/gravity-model.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "Introduction to Gravity Models of Migration & Trade"
2+
title: "Introduction to Gravity Models of Migration & Trade"
33
collection: lessons
44
layout: lesson
55
slug: gravity-model

js/lessonfilter.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ function lunrSearch(searchString, idx, corpus, featureList, uri) {
6363

6464
// Get lessons that contain search string using lunr index
6565
const results = idx.search(searchString);
66-
6766
// Get lessons from corpus that contain the search string
6867
let docs = results.filter(result => corpus.some(doc => result.ref === doc.url)).map(result => {
6968
let doc = corpus.find(lesson => lesson.url === result.ref);
@@ -105,11 +104,12 @@ function lunrSearch(searchString, idx, corpus, featureList, uri) {
105104
let condition = params.topic ? topicsArray.includes(type) : item.values().activity == type;
106105
// return items in list that are in search results and filter if clicked
107106
return docs.find((doc) => {
108-
if (doc.title === item.values().title) {
107+
let title = doc.title.includes('&') ? doc.title.replace('&', '&') : doc.title;
108+
if (title === item.values().title) {
109109
// update score values for item
110110
item.values().score = doc.score;
111111
// Could simply to just do Object.keys(params) > 1 here but in case we add more URI values this will explicitly check for filters along with search
112-
return ['topic', 'activity'].some(key => Object.keys(params).includes(key)) ? ((doc.title === item.values().title) && condition) : (doc.title === item.values().title);
112+
return ['topic', 'activity'].some(key => Object.keys(params).includes(key)) ? ((title === item.values().title) && condition) : (title === item.values().title);
113113
}
114114

115115
});

0 commit comments

Comments
 (0)