Skip to content

Commit ee5af5f

Browse files
committed
custom.js: deduplicate suggestions
1 parent a7286bd commit ee5af5f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

docs/js/custom.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,13 @@ $(document).ready(function() {
7979
})
8080
.addClass('external');
8181

82-
docsearch({
82+
let search = docsearch({
8383
container: '#docsearch',
8484
appId: '2DNYOU6YJZ',
8585
apiKey: '21ce3e522455e18e7ee16cf7d66edb4b',
8686
indexName: 'ezplatform',
8787
inputSelector: '#search_input',
88+
autocompleteOptions: { debug: false },
8889
transformData: function(hits) {
8990
const hitsPerPage = 10;
9091
const removedPattern = '¶';
@@ -127,6 +128,15 @@ $(document).ready(function() {
127128
},
128129
debug: false,
129130
});
131+
search.autocomplete.on('autocomplete:updated', event => {
132+
$('.ds-dropdown-menu .ds-suggestion').each(function() {
133+
let category = $(this).find('.algolia-docsearch-suggestion--subcategory-column');
134+
let content = $(this).find('.algolia-docsearch-suggestion--title');
135+
if (content.text().trim() == category.text().trim()) {
136+
content.remove();
137+
}
138+
});
139+
});
130140

131141
$(document).on('keydown keypress', 'form.md-search__form', function(event) {
132142
if (event.keyCode == 13) {

0 commit comments

Comments
 (0)