1
0
Fork 0

fix(docsearch): hide search suggestions if none

This commit is contained in:
François Chalifour 2020-04-04 12:40:40 +02:00
parent f944f30af7
commit d7d6984762

View file

@ -18,17 +18,18 @@ interface NoResultsScreenProps
}
export function NoResultsScreen(props: NoResultsScreenProps) {
const searchSuggestions: string[] = props.state.context.searchSuggestions;
return (
<div className="DocSearch-NoResults">
<p className="DocSearch-Title">
No results for "<strong>{props.state.query}</strong>".
</p>
<p>
Try searching for{' '}
{(props.state.context.searchSuggestions as string[])
.slice(0, 3)
.reduce<React.ReactNode[]>(
{searchSuggestions.length > 0 && (
<p>
Try searching for{' '}
{searchSuggestions.slice(0, 3).reduce<React.ReactNode[]>(
(acc, search) => [
...acc,
acc.length > 0 ? ', ' : '',
@ -46,8 +47,9 @@ export function NoResultsScreen(props: NoResultsScreenProps) {
],
[]
)}
&nbsp;...
</p>
&nbsp;...
</p>
)}
<p className="DocSearch-Help">
If you believe this query should return results,