Skip to content

Commit

Permalink
Fix lunr search (#1430)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang authored May 27, 2020
1 parent b067ee4 commit cb112e4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 18 deletions.
16 changes: 3 additions & 13 deletions scripts/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,9 @@ hexo.extend.helper.register('lunr_index', data => {
this.field('name', {boost: 10});
this.field('tags', {boost: 50});
this.field('description');
this.ref('id');

data.concat().sort((a, b) => {
if (a.name > b.name) {
return 1;
} else if (b.name > a.name) {
return -1;
}
return 0;
}).forEach((item, i) => {
const object = Object.assign({}, { id: i }, item);
this.add(object);
});
this.ref('name');

data.forEach(this.add, this);
});

return JSON.stringify(index);
Expand Down
4 changes: 2 additions & 2 deletions themes/navy/layout/partial/plugin.swig
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<li class="plugin on">
<li class="plugin on" id="{{ plugin.name }}">
<a href="{{ plugin.link }}" class="plugin-name" target="_blank">{{ plugin.name }}</a>
<p class="plugin-desc">{{ plugin.description }}</p>
<div class="plugin-tag-list">
{% for tag in plugin.tags %}
<a href="#{{ tag }}" class="plugin-tag">{{ tag }}</a>
{% endfor %}
</div>
</li>
</li>
4 changes: 2 additions & 2 deletions themes/navy/layout/partial/theme.swig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<li class="plugin on">
<li class="plugin on" id="{{ plugin.name }}">
<div class="plugin-screenshot">
<noscript>
<img src="{{ url_for('themes/screenshots/' + plugin.name + '.png') }}" class="plugin-screenshot-img" alt="{{ plugin.name }}">
Expand All @@ -15,4 +15,4 @@
<a href="#{{ tag }}" class="plugin-tag">{{ tag }}</a>
{% endfor %}
</div>
</li>
</li>
2 changes: 1 addition & 1 deletion themes/navy/source/js/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
}

for (i = 0; i < elementLen; i++) {
if (selected[i]) {
if (selected[elements[i].id]) {
addClass(elements[i], 'on');
} else {
removeClass(elements[i], 'on');
Expand Down

0 comments on commit cb112e4

Please sign in to comment.