Skip to content

Commit

Permalink
fix (non-working): add initialUiState to set default sort order (refs #2
Browse files Browse the repository at this point in the history
)
  • Loading branch information
kevinstadler committed Oct 8, 2024
1 parent 1c9e6d6 commit 6711115
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions components/instantsearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,22 @@ function InfiniteScroll(): ReactNode {

type RouteState = Record<string, string | undefined>;

const initialUiState = Object.fromEntries([
[
collectionName,
{
sortBy: `${collectionName}/sort/year:desc`,
},
],
]);

export function InstantSearch(props: InstantSearchProps): ReactNode {
const t = useTranslations("SearchPage");
const { children, filters, queryArgsToRefinementFields } = props;
return (
<InstantSearchNext
indexName={collectionName}
initialUiState={initialUiState}
routing={{
stateMapping: {
stateToRoute(uiState) {
Expand Down

0 comments on commit 6711115

Please sign in to comment.