chore: revert vault specific branch

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
Aaron Pham 2025-10-05 19:58:20 -04:00
parent f533902c75
commit 68682a8fe3
No known key found for this signature in database
GPG Key ID: 18974753009D2BFA

View File

@ -1,4 +1,4 @@
import FlexSearch, { DefaultDocumentSearchResults } from "flexsearch" import FlexSearch, { DefaultDocumentSearchResults, Id } from "flexsearch"
import type { ContentDetails } from "../../plugins/emitters/contentIndex" import type { ContentDetails } from "../../plugins/emitters/contentIndex"
import { SemanticClient, type SemanticResult } from "./semantic.inline" import { SemanticClient, type SemanticResult } from "./semantic.inline"
import { import {
@ -142,10 +142,6 @@ const index = new FlexSearch.Document<Item>({
field: "tags", field: "tags",
tokenize: "forward", tokenize: "forward",
}, },
{
field: "aliases",
tokenize: "forward",
},
], ],
}, },
}) })
@ -412,7 +408,6 @@ async function setupSearch(
removeAllChildren(preview) removeAllChildren(preview)
} }
searchLayout.classList.remove("display-results") searchLayout.classList.remove("display-results")
searchType = "basic" // reset search type after closing
searchButton.focus() searchButton.focus()
resetProgressBar() resetProgressBar()
} }
@ -429,9 +424,6 @@ async function setupSearch(
let currentHover: HTMLInputElement | null = null let currentHover: HTMLInputElement | null = null
async function shortcutHandler(e: HTMLElementEventMap["keydown"]) { async function shortcutHandler(e: HTMLElementEventMap["keydown"]) {
const paletteOpen = document.querySelector("search#palette-container") as HTMLDivElement
if (paletteOpen && paletteOpen.classList.contains("active")) return
if ((e.key === "/" || e.key === "k") && (e.ctrlKey || e.metaKey) && !e.shiftKey) { if ((e.key === "/" || e.key === "k") && (e.ctrlKey || e.metaKey) && !e.shiftKey) {
e.preventDefault() e.preventDefault()
const searchBarOpen = container.classList.contains("active") const searchBarOpen = container.classList.contains("active")
@ -505,8 +497,6 @@ async function setupSearch(
const formatForDisplay = (term: string, id: number, renderType: SearchType) => { const formatForDisplay = (term: string, id: number, renderType: SearchType) => {
const slug = idDataMap[id] const slug = idDataMap[id]
const aliases: string[] = data[slug].aliases ?? []
const target = aliases.find((alias) => alias.toLowerCase().includes(term.toLowerCase())) ?? ""
// Check if query contains title words (for boosting exact matches) // Check if query contains title words (for boosting exact matches)
const queryTokens = tokenizeTerm(term) const queryTokens = tokenizeTerm(term)
@ -516,14 +506,9 @@ async function setupSearch(
return { return {
id, id,
slug, slug,
title: title: renderType === "tags" ? data[slug].title : highlight(term, data[slug].title ?? ""),
renderType === "tags" || target
? data[slug].title
: highlight(term, data[slug].title ?? ""),
target,
content: highlight(term, data[slug].content ?? "", true), content: highlight(term, data[slug].content ?? "", true),
tags: highlightTags(term, data[slug].tags, renderType), tags: highlightTags(term, data[slug].tags, renderType),
aliases: aliases,
titleMatch, // Add title match flag for boosting titleMatch, // Add title match flag for boosting
} }
} }
@ -714,7 +699,7 @@ async function setupSearch(
const results = await index.searchAsync({ const results = await index.searchAsync({
query, query,
limit: Math.max(numSearchResults, 10000), limit: Math.max(numSearchResults, 10000),
index: ["title", "content", "aliases"], index: ["title", "content"],
tag: { tags: tag }, tag: { tags: tag },
}) })
if (token !== searchSeq) return if (token !== searchSeq) return
@ -735,7 +720,7 @@ async function setupSearch(
const results = await index.searchAsync({ const results = await index.searchAsync({
query: highlightTerm, query: highlightTerm,
limit: numSearchResults, limit: numSearchResults,
index: ["title", "content", "aliases"], index: ["title", "content"],
}) })
if (token !== searchSeq) return if (token !== searchSeq) return
searchResults = Object.values(results) searchResults = Object.values(results)
@ -760,7 +745,6 @@ async function setupSearch(
} }
const allIds: Set<number> = new Set([ const allIds: Set<number> = new Set([
...getByField("aliases"),
...getByField("title"), ...getByField("title"),
...getByField("content"), ...getByField("content"),
...getByField("tags"), ...getByField("tags"),
@ -980,7 +964,6 @@ async function fillDocument(data: ContentIndex) {
title: fileData.title, title: fileData.title,
content: fileData.content, content: fileData.content,
tags: fileData.tags, tags: fileData.tags,
aliases: fileData.aliases,
}), }),
) )
id++ id++