|
|
|
@ -67,6 +67,7 @@
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
<script>
|
|
|
|
|
async function run() {
|
|
|
|
|
const contentIndex = new FlexSearch.Document({
|
|
|
|
|
cache: true,
|
|
|
|
|
charset: "latin:extra",
|
|
|
|
@ -89,6 +90,7 @@
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const { content } = await fetchData()
|
|
|
|
|
for (const [key, value] of Object.entries(content)) {
|
|
|
|
|
contentIndex.add({
|
|
|
|
|
id: key,
|
|
|
|
@ -147,7 +149,7 @@
|
|
|
|
|
window.location.href = "{{.Site.BaseURL}}" + `${id}#:~:text=${encodeURIComponent(term)}`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const fetch = id => ({
|
|
|
|
|
const formatForDisplay = id => ({
|
|
|
|
|
id,
|
|
|
|
|
url: id,
|
|
|
|
|
title: content[id].title,
|
|
|
|
@ -185,7 +187,7 @@
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const allIds = new Set([...getByField('title'), ...getByField('content')])
|
|
|
|
|
const finalResults = [...allIds].map(fetch)
|
|
|
|
|
const finalResults = [...allIds].map(formatForDisplay)
|
|
|
|
|
|
|
|
|
|
// display
|
|
|
|
|
if (finalResults.length === 0) {
|
|
|
|
@ -210,6 +212,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const searchContainer = document.getElementById("search-container")
|
|
|
|
|
|
|
|
|
|
function openSearch() {
|
|
|
|
|
if (searchContainer.style.display === "none" || searchContainer.style.display === "") {
|
|
|
|
|
source.value = ""
|
|
|
|
@ -251,5 +254,7 @@
|
|
|
|
|
evt.stopPropagation()
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
run()
|
|
|
|
|
</script>
|
|
|
|
|