From 970a30a139953c8d58705474b7910a64153e9466 Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Thu, 1 Feb 2024 23:57:17 -0800 Subject: [PATCH] chore: fmt --- quartz/components/scripts/search.inline.ts | 27 +++++++++++++--------- quartz/components/styles/search.scss | 2 +- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/quartz/components/scripts/search.inline.ts b/quartz/components/scripts/search.inline.ts index c960f5e47..17f3e1ba8 100644 --- a/quartz/components/scripts/search.inline.ts +++ b/quartz/components/scripts/search.inline.ts @@ -76,8 +76,9 @@ function highlight(searchTerm: string, text: string, trim?: boolean) { }) .join(" ") - return `${startIndex === 0 ? "" : "..."}${slice}${endIndex === tokenizedText.length - 1 ? "" : "..." - }` + return `${startIndex === 0 ? "" : "..."}${slice}${ + endIndex === tokenizedText.length - 1 ? "" : "..." + }` } function highlightHTML(searchTerm: string, innerHTML: string) { @@ -276,13 +277,15 @@ document.addEventListener("nav", async (e: CustomEventMap["nav"]) => { return [] } - return tags.map(tag => { - if (tag.toLowerCase().includes(term.toLowerCase())) { - return `
  • #${tag}

  • ` - } else { - return `
  • #${tag}

  • ` - } - }).slice(0, numTagResults) + return tags + .map((tag) => { + if (tag.toLowerCase().includes(term.toLowerCase())) { + return `
  • #${tag}

  • ` + } else { + return `
  • #${tag}

  • ` + } + }) + .slice(0, numTagResults) } function resolveUrl(slug: FullSlug): URL { @@ -299,7 +302,7 @@ document.addEventListener("nav", async (e: CustomEventMap["nav"]) => { async function onMouseEnter(ev: MouseEvent) { if (!ev.target) return - currentHover?.classList.remove('focus') + currentHover?.classList.remove("focus") currentHover?.blur() const target = ev.target as HTMLInputElement await displayPreview(target) @@ -392,7 +395,9 @@ document.addEventListener("nav", async (e: CustomEventMap["nav"]) => { preview.replaceChildren(previewInner) // scroll to longest - const highlights = [...preview.querySelectorAll(".highlight")].sort((a, b) => b.innerHTML.length - a.innerHTML.length) + const highlights = [...preview.querySelectorAll(".highlight")].sort( + (a, b) => b.innerHTML.length - a.innerHTML.length, + ) highlights[0]?.scrollIntoView() } diff --git a/quartz/components/styles/search.scss b/quartz/components/styles/search.scss index df4f5bab5..b4bb64a00 100644 --- a/quartz/components/styles/search.scss +++ b/quartz/components/styles/search.scss @@ -204,7 +204,7 @@ line-height: 1.4rem; font-weight: bold; color: var(--secondary); - + &.match-tag { color: var(--tertiary); }