Skip to content

Commit 51d738b

Browse files
committed
Don't index keywords as a single long string
1 parent a93a8f0 commit 51d738b

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

addon/services/docs-search.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,14 @@ export default Service.extend({
3838
let doc = result.document;
3939
if (doc.type === 'class') {
4040
console.groupCollapsed(`Class: %c${doc.title}`, 'font-family: monospace');
41-
for (let match of Object.values(result.resultInfo.matchData.metadata)) {
41+
for (let [term, match] of Object.entries(result.resultInfo.matchData.metadata)) {
4242
for (let [key, data] of Object.entries(match)) {
4343
if (key === 'keywords') {
44-
for (let position of data.position) {
45-
console.log(`%c${extractKeyword(doc.keywords, position)} %c(field)`, 'font-family: monospace', 'font-family: inherit');
44+
let test = term.toLowerCase();
45+
for (let keyword of doc.keywords) {
46+
if (keyword.toLowerCase().indexOf(test) !== -1) {
47+
console.log(`%c${keyword} %c(field)`, 'font-family: monospace; font-weight: bold', 'font-family: inherit; font-weight: normal');
48+
}
4649
}
4750
} else {
4851
for (let position of data.position) {

lib/broccoli/search-indexer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ module.exports = class SearchIndexCompiler extends Writer {
7373
title: normalizeText(contents.title),
7474
text: normalizeText(contents.body),
7575
route: routePath.replace(/\//g, '.'),
76-
keywords: '', // TODO allow for specifying keywords
76+
keywords: [], // TODO allow for specifying keywords
7777
};
7878
}
7979
}
@@ -97,7 +97,7 @@ module.exports = class SearchIndexCompiler extends Writer {
9797
type: 'class',
9898
title: item.attributes.name,
9999
text: htmlEntities.decode(striptags(normalizeText(item.attributes.description))),
100-
keywords: keywords.join('\0'),
100+
keywords: keywords,
101101
class: item
102102
};
103103
}

0 commit comments

Comments
 (0)