From 827dd918476e225238d8412551df2866e4f9e616 Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Sat, 12 Aug 2023 07:03:11 +0000
Subject: [PATCH] format, make search async

---
 quartz/plugins/transformers/ofm.ts         |    2 +-
 quartz/components/scripts/search.inline.ts |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/quartz/components/scripts/search.inline.ts b/quartz/components/scripts/search.inline.ts
index 40d0bc2..9fc0c0e 100644
--- a/quartz/components/scripts/search.inline.ts
+++ b/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[])
diff --git a/quartz/plugins/transformers/ofm.ts b/quartz/plugins/transformers/ofm.ts
index 794b554..6083a61 100644
--- a/quartz/plugins/transformers/ofm.ts
+++ b/quartz/plugins/transformers/ofm.ts
@@ -165,7 +165,7 @@
           const fp = rawFp ?? ""
           const anchor = rawHeader?.trim().slice(1)
           const displayAnchor = anchor ? `#${slugAnchor(anchor)}` : ""
-          const displayAlias = rawAlias ?? rawHeader?.replace("#", "|") ?? "" 
+          const displayAlias = rawAlias ?? rawHeader?.replace("#", "|") ?? ""
           const embedDisplay = value.startsWith("!") ? "!" : ""
           return `${embedDisplay}[[${fp}${displayAnchor}${displayAlias}]]`
         })

--
Gitblit v1.10.0