From 2d6dc176c3e1fbb520a5da1beb60bbb1d8e948ba Mon Sep 17 00:00:00 2001
From: Pelayo Arbués <gonzalezpelayo@gmail.com>
Date: Thu, 31 Aug 2023 19:12:06 +0000
Subject: [PATCH] Adds Pelayo Arbues to showcase (#435)
---
quartz/components/scripts/search.inline.ts | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/quartz/components/scripts/search.inline.ts b/quartz/components/scripts/search.inline.ts
index 038566c..ef26ba3 100644
--- a/quartz/components/scripts/search.inline.ts
+++ b/quartz/components/scripts/search.inline.ts
@@ -1,7 +1,7 @@
import { Document } from "flexsearch"
import { ContentDetails } from "../../plugins/emitters/contentIndex"
import { registerEscapeHandler, removeAllChildren } from "./util"
-import { FullSlug, getFullSlug, resolveRelative, simplifySlug } from "../../util/path"
+import { FullSlug, resolveRelative } from "../../util/path"
interface Item {
id: number
@@ -64,6 +64,7 @@
}
const encoder = (str: string) => str.toLowerCase().split(/([^a-z]|[^\x00-\x7F])/)
+let prevShortcutHandler: ((e: HTMLElementEventMap["keydown"]) => void) | undefined = undefined
document.addEventListener("nav", async (e: unknown) => {
const currentSlug = (e as CustomEventMap["nav"]).detail.url
@@ -127,6 +128,7 @@
button.addEventListener("click", () => {
const targ = resolveRelative(currentSlug, slug)
window.spaNavigate(new URL(targ, window.location.toString()))
+ hideSearch()
})
return button
}
@@ -159,8 +161,12 @@
displayResults(finalResults)
}
- document.removeEventListener("keydown", shortcutHandler)
+ if (prevShortcutHandler) {
+ document.removeEventListener("keydown", prevShortcutHandler)
+ }
+
document.addEventListener("keydown", shortcutHandler)
+ prevShortcutHandler = shortcutHandler
searchIcon?.removeEventListener("click", showSearch)
searchIcon?.addEventListener("click", showSearch)
searchBar?.removeEventListener("input", onType)
--
Gitblit v1.10.0