fix(docsearch): don't request Algolia on start screen
This commit is contained in:
parent
bf86a1d09f
commit
e6614359ab
1 changed files with 29 additions and 29 deletions
|
|
@ -104,6 +104,35 @@ export function DocSearch({
|
|||
setState(state as any);
|
||||
},
|
||||
getSources({ query, state, setContext, setStatus }) {
|
||||
if (!query) {
|
||||
return [
|
||||
{
|
||||
onSelect({ suggestion }) {
|
||||
saveRecentSearch(suggestion);
|
||||
onClose();
|
||||
},
|
||||
getSuggestionUrl({ suggestion }) {
|
||||
return suggestion.url;
|
||||
},
|
||||
getSuggestions() {
|
||||
return recentSearches.getAll();
|
||||
},
|
||||
},
|
||||
{
|
||||
onSelect({ suggestion }) {
|
||||
saveRecentSearch(suggestion);
|
||||
onClose();
|
||||
},
|
||||
getSuggestionUrl({ suggestion }) {
|
||||
return suggestion.url;
|
||||
},
|
||||
getSuggestions() {
|
||||
return favoriteSearches.getAll();
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
return getAlgoliaHits({
|
||||
searchClient,
|
||||
queries: [
|
||||
|
|
@ -174,35 +203,6 @@ export function DocSearch({
|
|||
});
|
||||
}
|
||||
|
||||
if (!query) {
|
||||
return [
|
||||
{
|
||||
onSelect({ suggestion }) {
|
||||
saveRecentSearch(suggestion);
|
||||
onClose();
|
||||
},
|
||||
getSuggestionUrl({ suggestion }) {
|
||||
return suggestion.url;
|
||||
},
|
||||
getSuggestions() {
|
||||
return recentSearches.getAll();
|
||||
},
|
||||
},
|
||||
{
|
||||
onSelect({ suggestion }) {
|
||||
saveRecentSearch(suggestion);
|
||||
onClose();
|
||||
},
|
||||
getSuggestionUrl({ suggestion }) {
|
||||
return suggestion.url;
|
||||
},
|
||||
getSuggestions() {
|
||||
return favoriteSearches.getAll();
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
return Object.values<DocSearchHit[]>(sources).map(items => {
|
||||
return {
|
||||
onSelect({ suggestion }) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue