Skip to content

Commit e208097

Browse files
committed
custom.js: Factorize hitsPerPage, remove removedPattern
removedPattern is unnecessary as entries are now cleaned at indexation time.
1 parent e9062ea commit e208097

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

docs/js/custom.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,22 +110,21 @@ $(document).ready(function() {
110110
})
111111
.addClass('external');
112112

113+
const hitsPerPage = 10;
113114
let search = docsearch({
114115
container: '#docsearch',
115116
appId: '2DNYOU6YJZ',
116117
apiKey: '21ce3e522455e18e7ee16cf7d66edb4b',
117118
indexName: 'ezplatform',
118119
inputSelector: '#search_input',
119120
transformData: function(hits) {
120-
const hitsPerPage = 10;
121-
const removedPattern = '¶';
122121
$.each(hits, function(index, hit) {
123122
for (let lvl=2; lvl<=6; lvl++) {
124123
if (null !== hit.hierarchy['lvl'+lvl]) {
125-
hits[index].hierarchy['lvl' + lvl] = hit.hierarchy['lvl' + lvl].replace(removedPattern, '');
124+
hits[index].hierarchy['lvl' + lvl] = hit.hierarchy['lvl' + lvl];
126125
}
127126
if ('undefined' !== typeof hit._highlightResult.hierarchy['lvl'+lvl]) {
128-
hits[index]._highlightResult.hierarchy['lvl'+lvl].value = hit._highlightResult.hierarchy['lvl'+lvl].value.replace(removedPattern, '');
127+
hits[index]._highlightResult.hierarchy['lvl'+lvl].value = hit._highlightResult.hierarchy['lvl'+lvl].value;
129128
}
130129
}
131130
});
@@ -147,7 +146,7 @@ $(document).ready(function() {
147146
},
148147
algoliaOptions: {
149148
facetFilters: ['lang:en', 'version:' + branchName],
150-
hitsPerPage: 10,
149+
hitsPerPage: hitsPerPage,
151150
},
152151
handleSelected: function (input, event, suggestion, datasetNumber, context) {
153152
if (context.selectionMethod == 'click') {

0 commit comments

Comments
 (0)