mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-23 03:56:23 +00:00
chore: fmt
This commit is contained in:
parent
dc62aeb213
commit
970a30a139
2 changed files with 17 additions and 12 deletions
|
@ -76,8 +76,9 @@ function highlight(searchTerm: string, text: string, trim?: boolean) {
|
||||||
})
|
})
|
||||||
.join(" ")
|
.join(" ")
|
||||||
|
|
||||||
return `${startIndex === 0 ? "" : "..."}${slice}${endIndex === tokenizedText.length - 1 ? "" : "..."
|
return `${startIndex === 0 ? "" : "..."}${slice}${
|
||||||
}`
|
endIndex === tokenizedText.length - 1 ? "" : "..."
|
||||||
|
}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function highlightHTML(searchTerm: string, innerHTML: string) {
|
function highlightHTML(searchTerm: string, innerHTML: string) {
|
||||||
|
@ -276,13 +277,15 @@ document.addEventListener("nav", async (e: CustomEventMap["nav"]) => {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
return tags.map(tag => {
|
return tags
|
||||||
if (tag.toLowerCase().includes(term.toLowerCase())) {
|
.map((tag) => {
|
||||||
return `<li><p class="match-tag">#${tag}</p></li>`
|
if (tag.toLowerCase().includes(term.toLowerCase())) {
|
||||||
} else {
|
return `<li><p class="match-tag">#${tag}</p></li>`
|
||||||
return `<li><p>#${tag}</p></li>`
|
} else {
|
||||||
}
|
return `<li><p>#${tag}</p></li>`
|
||||||
}).slice(0, numTagResults)
|
}
|
||||||
|
})
|
||||||
|
.slice(0, numTagResults)
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveUrl(slug: FullSlug): URL {
|
function resolveUrl(slug: FullSlug): URL {
|
||||||
|
@ -299,7 +302,7 @@ document.addEventListener("nav", async (e: CustomEventMap["nav"]) => {
|
||||||
|
|
||||||
async function onMouseEnter(ev: MouseEvent) {
|
async function onMouseEnter(ev: MouseEvent) {
|
||||||
if (!ev.target) return
|
if (!ev.target) return
|
||||||
currentHover?.classList.remove('focus')
|
currentHover?.classList.remove("focus")
|
||||||
currentHover?.blur()
|
currentHover?.blur()
|
||||||
const target = ev.target as HTMLInputElement
|
const target = ev.target as HTMLInputElement
|
||||||
await displayPreview(target)
|
await displayPreview(target)
|
||||||
|
@ -392,7 +395,9 @@ document.addEventListener("nav", async (e: CustomEventMap["nav"]) => {
|
||||||
preview.replaceChildren(previewInner)
|
preview.replaceChildren(previewInner)
|
||||||
|
|
||||||
// scroll to longest
|
// 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()
|
highlights[0]?.scrollIntoView()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue