UseSearchPage hook
const searchPage = useSearchPage();
When content element add-on is located on search page it may need to access data about current page.
This hook returns the object with data or null if it's not being used on the search page.
The data contains following properties:
| Property | Type | Description |
|---|---|---|
| keywords | string | The search keywords. |
| selectedFacets | Array<RangeFacet | ListFacet> | The selected facet filters. |
The RangeFacet type contains following properties:
| Property | Type | Description |
|---|---|---|
| name | string | The facet name. |
| minValue | number | The minimum value of the range facet. |
| maxValue | number | The maximum value of the range facet. |
The ListFacet type contains following properties:
| Property | Type | Description |
|---|---|---|
| name | string | The facet name. |
| values | Array<string> | The facet values. |
Example:
const searchPage = useSearchPage();
if (!searchPage)
return null;
const { keywords, selectedFacets } = searchPage;