From 5749fbbd750f8f4116a0eebff1a5f758a5328549 Mon Sep 17 00:00:00 2001
From: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 22 Jul 2024 22:30:28 +0000
Subject: [PATCH] chore(deps): bump @floating-ui/dom from 1.6.5 to 1.6.8 (#1290)
---
quartz/components/scripts/search.inline.ts | 33 ++++++++++++++++++++++++++++-----
1 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/quartz/components/scripts/search.inline.ts b/quartz/components/scripts/search.inline.ts
index a75f4ff..72be6b8 100644
--- a/quartz/components/scripts/search.inline.ts
+++ b/quartz/components/scripts/search.inline.ts
@@ -21,6 +21,7 @@
encode: encoder,
document: {
id: "id",
+ tag: "tags",
index: [
{
field: "title",
@@ -405,11 +406,33 @@
let searchResults: FlexSearch.SimpleDocumentSearchResultSetUnit[]
if (searchType === "tags") {
- searchResults = await index.searchAsync({
- query: currentSearchTerm.substring(1),
- limit: numSearchResults,
- index: ["tags"],
- })
+ currentSearchTerm = currentSearchTerm.substring(1).trim()
+ const separatorIndex = currentSearchTerm.indexOf(" ")
+ if (separatorIndex != -1) {
+ // search by title and content index and then filter by tag (implemented in flexsearch)
+ const tag = currentSearchTerm.substring(0, separatorIndex)
+ const query = currentSearchTerm.substring(separatorIndex + 1).trim()
+ searchResults = await index.searchAsync({
+ query: query,
+ // return at least 10000 documents, so it is enough to filter them by tag (implemented in flexsearch)
+ limit: Math.max(numSearchResults, 10000),
+ index: ["title", "content"],
+ tag: tag,
+ })
+ for (let searchResult of searchResults) {
+ searchResult.result = searchResult.result.slice(0, numSearchResults)
+ }
+ // set search type to basic and remove tag from term for proper highlightning and scroll
+ searchType = "basic"
+ currentSearchTerm = query
+ } else {
+ // default search by tags index
+ searchResults = await index.searchAsync({
+ query: currentSearchTerm,
+ limit: numSearchResults,
+ index: ["tags"],
+ })
+ }
} else if (searchType === "basic") {
searchResults = await index.searchAsync({
query: currentSearchTerm,
--
Gitblit v1.10.0