Jacky Zhao
2023-08-12 827dd918476e225238d8412551df2866e4f9e616
format, make search async
2 files modified
4 ■■■■ changed files
quartz/components/scripts/search.inline.ts 4 ●●●● patch | view | raw | blame | history
quartz/plugins/transformers/ofm.ts patch | view | raw | blame | history
quartz/components/scripts/search.inline.ts
@@ -139,9 +139,9 @@
    }
  }
  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[])
quartz/plugins/transformers/ofm.ts