From 66f1a20d0b46df1777eb5c52ba33193fbaa6591a Mon Sep 17 00:00:00 2001 From: Matthieu Dumont <5095856+Jerska@users.noreply.github.com> Date: Thu, 20 Sep 2018 07:52:21 +0000 Subject: [PATCH] feat(instantsearch): add support for hitsPerPage configuration (#74) * feat(instantsearch): add support for hitsPerPage configuration * docs(instantsearch): document hitsPerPage option --- app/README.md | 1 + app/src/AlgoliasearchZendeskHC.js | 1 + app/src/instantsearch.js | 2 ++ docs/documentation.md | 1 + 4 files changed, 5 insertions(+) diff --git a/app/README.md b/app/README.md index 71834024..592fae3c 100644 --- a/app/README.md +++ b/app/README.md @@ -94,6 +94,7 @@ Here is a full breakdown of the available options for the JavaScript library: }, instantsearch: { enabled: true, // is the instantsearch feature enabled? + hitsPerPage: 20, // the number of suggestions to display paginationSelector: '.pagination', // the DOM selector for the current pagination (to hide it) reuseAutocomplete: false, // do not add a search input for the instant-search page hideAutocomplete: true, // whether or not to hide the autocomplete on the instantsearch page (ignored if reuseAutocomplete is used) diff --git a/app/src/AlgoliasearchZendeskHC.js b/app/src/AlgoliasearchZendeskHC.js index c2497e1e..cc14b6a2 100644 --- a/app/src/AlgoliasearchZendeskHC.js +++ b/app/src/AlgoliasearchZendeskHC.js @@ -28,6 +28,7 @@ const optionsStructure = {required: true, type: 'Object', children: { indexPrefix: {type: 'string', value: 'zendesk_'}, instantsearch: {type: 'Object', value: {}, children: { enabled: {type: 'boolean', value: true}, + hitsPerPage: {type: 'number', value: 20}, paginationSelector: {type: 'string', value: '.pagination'}, reuseAutocomplete: {type: 'boolean', value: false}, hideAutocomplete: {type: 'boolean', value: true}, diff --git a/app/src/instantsearch.js b/app/src/instantsearch.js index 642ec60c..3e521189 100644 --- a/app/src/instantsearch.js +++ b/app/src/instantsearch.js @@ -70,6 +70,7 @@ class InstantSearch { highlightColor, instantsearch: { enabled, + hitsPerPage, selector, paginationSelector, reuseAutocomplete, @@ -190,6 +191,7 @@ class InstantSearch { this.instantsearch.addWidget( instantsearch.widgets.hits({ container: '#algolia-hits', + hitsPerPage, templates: { empty: templates.instantsearch.noResult, item: templates.instantsearch.hit diff --git a/docs/documentation.md b/docs/documentation.md index 8788aaca..e9e963c2 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -86,6 +86,7 @@ Here is a full breakdown of the available options for the JavaScript library: }, instantsearch: { enabled: true, // is the instantsearch feature enabled? + hitsPerPage: 20, // the number of suggestions to display paginationSelector: '.pagination', // the DOM selector for the current pagination (to hide it) reuseAutocomplete: false, // do not add a search input for the instant-search page hideAutocomplete: true, // whether or not to hide the autocomplete on the instantsearch page (ignored if reuseAutocomplete is used)