mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-26 13:26:22 +00:00
fix: parallelize search indexing
This commit is contained in:
parent
ee868b2d79
commit
18cd58617d
1 changed files with 13 additions and 8 deletions
|
@ -464,8 +464,8 @@ document.addEventListener("nav", async (e: CustomEventMap["nav"]) => {
|
||||||
searchBar?.addEventListener("input", onType)
|
searchBar?.addEventListener("input", onType)
|
||||||
window.addCleanup(() => searchBar?.removeEventListener("input", onType))
|
window.addCleanup(() => searchBar?.removeEventListener("input", onType))
|
||||||
|
|
||||||
await fillDocument(data)
|
|
||||||
registerEscapeHandler(container, hideSearch)
|
registerEscapeHandler(container, hideSearch)
|
||||||
|
await fillDocument(data)
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -475,13 +475,18 @@ document.addEventListener("nav", async (e: CustomEventMap["nav"]) => {
|
||||||
*/
|
*/
|
||||||
async function fillDocument(data: { [key: FullSlug]: ContentDetails }) {
|
async function fillDocument(data: { [key: FullSlug]: ContentDetails }) {
|
||||||
let id = 0
|
let id = 0
|
||||||
|
const promises: Array<Promise<unknown>> = []
|
||||||
for (const [slug, fileData] of Object.entries<ContentDetails>(data)) {
|
for (const [slug, fileData] of Object.entries<ContentDetails>(data)) {
|
||||||
await index.addAsync(id++, {
|
promises.push(
|
||||||
|
index.addAsync(id++, {
|
||||||
id,
|
id,
|
||||||
slug: slug as FullSlug,
|
slug: slug as FullSlug,
|
||||||
title: fileData.title,
|
title: fileData.title,
|
||||||
content: fileData.content,
|
content: fileData.content,
|
||||||
tags: fileData.tags,
|
tags: fileData.tags,
|
||||||
})
|
}),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return await Promise.all(promises)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue