Last active
January 14, 2025 15:55
-
-
Save dcooney/d738dcc29d374efcf60a908184279982 to your computer and use it in GitHub Desktop.
Algolia InstantSearch No Results
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function NoResultsAppBoundary(props) { | |
const {children} = props | |
const {results} = useInstantSearch() | |
if (!results?.nbHits || !term) { | |
return ( | |
<Container className={styles.noResults}> | |
<Blocks blocks={post?.blocks} /> | |
</Container> | |
) | |
} | |
return children | |
} | |
<InstantSearch | |
indexName={config.lots.name} | |
searchClient={algoliaClient} | |
> | |
<NoResultsAppBoundary> | |
<Index indexName={config.lots.name}> | |
<NoResultsBoundary> | |
<Configure filters={`taxonomies.run_date.timestamp>=${today}`} /> | |
<CustomHits {...config.lots} /> | |
</NoResultsBoundary> | |
</Index> | |
<Index indexName={config.results.name}> | |
<NoResultsBoundary> | |
<CustomHits {...config.results} /> | |
</NoResultsBoundary> | |
</Index> | |
<Index indexName={config.search.name}> | |
<NoResultsBoundary> | |
<CustomHits {...config.search} /> | |
</NoResultsBoundary> | |
</Index> | |
</NoResultsAppBoundary> | |
</InstantSearch> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment