Skip to content

Commit 4c97375

Browse files
fix(qs): rename categoriesLimit to itemsWithCategories (#491)
This renames the Query Suggestions plugin option `categoriesLimit` to `itemsWithCategories`. (The previous options were also inverted in the QS plugin, so this rename fixes it.) BREAKING CHANGE
1 parent 965138c commit 4c97375

File tree

5 files changed

+10
-11
lines changed

5 files changed

+10
-11
lines changed

examples/query-suggestions-with-inline-categories/app.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ const querySuggestionsPlugin = createQuerySuggestionsPlugin({
2424
'exact_matches',
2525
'categories',
2626
],
27-
categoriesPerItem: 1,
28-
categoriesLimit: 2,
27+
categoriesPerItem: 2,
2928
transformSource: ({ source, onTapAhead }) => {
3029
return {
3130
...source,

packages/autocomplete-plugin-query-suggestions/src/createQuerySuggestionsPlugin.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export type CreateQuerySuggestionsPluginParams<
3030
* The number of items to display categories for.
3131
* @default 1
3232
*/
33-
categoriesLimit?: number;
33+
itemsWithCategories?: number;
3434
/**
3535
* The number of categories to display per item.
3636
* @default 1
@@ -46,8 +46,8 @@ export function createQuerySuggestionsPlugin<
4646
getSearchParams = () => ({}),
4747
transformSource = ({ source }) => source,
4848
categoryAttribute,
49+
itemsWithCategories = 1,
4950
categoriesPerItem = 1,
50-
categoriesLimit = 1,
5151
}: CreateQuerySuggestionsPluginParams<TItem>): AutocompletePlugin<
5252
TItem,
5353
undefined
@@ -88,15 +88,15 @@ export function createQuerySuggestionsPlugin<
8888
AutocompleteQuerySuggestionsHit<typeof indexName>
8989
> = [current];
9090

91-
if (i <= categoriesPerItem - 1) {
91+
if (i <= itemsWithCategories - 1) {
9292
const categories = getAttributeValueByPath(
9393
current,
9494
Array.isArray(categoryAttribute)
9595
? categoryAttribute
9696
: [categoryAttribute]
9797
)
9898
.map((x) => x.value)
99-
.slice(0, categoriesLimit);
99+
.slice(0, categoriesPerItem);
100100

101101
for (const category of categories) {
102102
items.push({

packages/website/docs/adding-suggested-searches.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const querySuggestionsPluginWithCategories = createQuerySuggestionsPlugin({
2323
'exact_matches',
2424
'categories',
2525
],
26-
categoriesLimit: 2,
26+
itemsWithCategories: 2,
2727
categoriesPerItem: 2,
2828
});
2929

@@ -148,7 +148,7 @@ To display categories with the suggestions, you need to define the attribute to
148148

149149
In this example, the category data is stored in the nested attribute `instant_search.facets.exact_matches.categories`. With this structure, you need to provide the path `["instant_search", "facets", "exact_matches", "categories"]` as the `categoryAttribute`.
150150

151-
You can also set the number of items to display categories for using `categoriesLimit` and the maximum number of categories to display per item using `categoriesPerItem`. Both default to `1`.
151+
You can also set the number of items to display categories for using `itemsWithCategories` and the maximum number of categories to display per item using `categoriesPerItem`. Both default to `1`.
152152

153153
```js title="index.js"
154154
import { autocomplete } from '@algolia/autocomplete-js';
@@ -170,7 +170,7 @@ const querySuggestionsPlugin = createQuerySuggestionsPlugin({
170170
'exact_matches',
171171
'categories',
172172
],
173-
categoriesLimit: 2,
173+
itemsWithCategories: 2,
174174
categoriesPerItem: 2,
175175
});
176176

packages/website/docs/createQuerySuggestionsPlugin.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ const querySuggestionsPlugin = createQuerySuggestionsPlugin({
179179
});
180180
```
181181

182-
### `categoriesLimit`
182+
### `itemsWithCategories`
183183

184184
> `number` | defaults to `1`
185185

packages/website/docs/introduction.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const querySuggestionsPlugin = createQuerySuggestionsPlugin({
2525
'exact_matches',
2626
'categories',
2727
],
28-
categoriesLimit: 2,
28+
categoriesPerItem: 2,
2929
});
3030
const productsPlugin = createProductsPlugin();
3131
const productsPluginWithHeader = createProductsPlugin({

0 commit comments

Comments
 (0)