From 6711115d2877012544af7b0e6618c98381801c91 Mon Sep 17 00:00:00 2001 From: Kevin Stadler Date: Tue, 8 Oct 2024 13:26:58 +0200 Subject: [PATCH] fix (non-working): add initialUiState to set default sort order (refs #2) --- components/instantsearch.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/components/instantsearch.tsx b/components/instantsearch.tsx index 2521ff9..a0b3d1e 100644 --- a/components/instantsearch.tsx +++ b/components/instantsearch.tsx @@ -84,12 +84,22 @@ function InfiniteScroll(): ReactNode { type RouteState = Record; +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 (