fix(docsearch): hide search suggestions if none
This commit is contained in:
parent
f944f30af7
commit
d7d6984762
1 changed files with 9 additions and 7 deletions
|
|
@ -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) {
|
|||
],
|
||||
[]
|
||||
)}
|
||||
...
|
||||
</p>
|
||||
...
|
||||
</p>
|
||||
)}
|
||||
|
||||
<p className="DocSearch-Help">
|
||||
If you believe this query should return results,
|
||||
|
|
|
|||
Loading…
Reference in a new issue