format, make search async
This commit is contained in:
		
							parent
							
								
									e1dd6aee86
								
							
						
					
					
						commit
						827dd91847
					
				
					 2 changed files with 3 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -139,9 +139,9 @@ document.addEventListener("nav", async (e: unknown) => {
 | 
			
		|||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function onType(e: HTMLElementEventMap["input"]) {
 | 
			
		||||
  async function onType(e: HTMLElementEventMap["input"]) {
 | 
			
		||||
    const term = (e.target as HTMLInputElement).value
 | 
			
		||||
    const searchResults = index?.search(term, numSearchResults) ?? []
 | 
			
		||||
    const searchResults = (await index?.searchAsync(term, numSearchResults)) ?? []
 | 
			
		||||
    const getByField = (field: string): CanonicalSlug[] => {
 | 
			
		||||
      const results = searchResults.filter((x) => x.field === field)
 | 
			
		||||
      return results.length === 0 ? [] : ([...results[0].result] as CanonicalSlug[])
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue