fix(deps): update dependency flexsearch to v0.8.205 (#999)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Robert Kaussow <mail@thegeeklab.de>
This commit is contained in:
parent
cc623cb688
commit
c7234c1589
|
@ -1,6 +0,0 @@
|
|||
{{ if default true .Site.Params.geekdocSearch }}
|
||||
<script defer src="{{ index (index .Site.Data.assets "search.js") "src" | relURL }}"></script>
|
||||
{{- $searchConfigFile := printf "search/%s.config.json" .Language.Lang -}}
|
||||
{{- $searchConfig := resources.Get "search/config.json" | resources.ExecuteAsTemplate $searchConfigFile . | resources.Minify -}}
|
||||
{{- $searchConfig.Publish -}}
|
||||
{{ end }}
|
|
@ -1,4 +1,9 @@
|
|||
{{ if default true .Site.Params.geekdocSearch }}
|
||||
<script defer src="{{ index (index .Site.Data.assets "search.js") "src" | relURL }}"></script>
|
||||
{{- $searchConfigFile := printf "search/%s.config.json" .Language.Lang -}}
|
||||
{{- $searchConfig := resources.Get "search/config.json" | resources.ExecuteAsTemplate $searchConfigFile . | resources.Minify -}}
|
||||
{{- $searchConfig.Publish -}}
|
||||
|
||||
<div class="gdoc-search flex align-center">
|
||||
<svg class="gdoc-icon gdoc_search"><use xlink:href="#gdoc_search"></use></svg>
|
||||
<input
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
"dependencies": {
|
||||
"@cfworker/json-schema": "4.1.1",
|
||||
"clipboard": "2.0.11",
|
||||
"flexsearch": "0.7.43",
|
||||
"flexsearch": "0.8.205",
|
||||
"katex": "0.16.22",
|
||||
"lodash": "4.17.21",
|
||||
"mermaid": "11.7.0",
|
||||
|
@ -5292,9 +5292,35 @@
|
|||
"license": "ISC"
|
||||
},
|
||||
"node_modules/flexsearch": {
|
||||
"version": "0.7.43",
|
||||
"resolved": "https://registry.npmjs.org/flexsearch/-/flexsearch-0.7.43.tgz",
|
||||
"integrity": "sha512-c5o/+Um8aqCSOXGcZoqZOm+NqtVwNsvVpWv6lfmSclU954O3wvQKxxK8zj74fPaSJbXpSLTs4PRhh+wnoCXnKg==",
|
||||
"version": "0.8.205",
|
||||
"resolved": "https://registry.npmjs.org/flexsearch/-/flexsearch-0.8.205.tgz",
|
||||
"integrity": "sha512-REFjMqy86DKkCTJ4gIE42c9MVm9t1vUWfEub/8taixYuhvyu4jd4XmFALk5VuKW4GH4VLav8A4BJboTsslHF1w==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/ts-thomas"
|
||||
},
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/flexsearch"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://patreon.com/user?u=96245532"
|
||||
},
|
||||
{
|
||||
"type": "liberapay",
|
||||
"url": "https://liberapay.com/ts-thomas"
|
||||
},
|
||||
{
|
||||
"type": "paypal",
|
||||
"url": "https://www.paypal.com/donate/?hosted_button_id=GEVR88FC9BWRW"
|
||||
},
|
||||
{
|
||||
"type": "bountysource",
|
||||
"url": "https://salt.bountysource.com/teams/ts-thomas"
|
||||
}
|
||||
],
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/fn.name": {
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
"dependencies": {
|
||||
"@cfworker/json-schema": "4.1.1",
|
||||
"clipboard": "2.0.11",
|
||||
"flexsearch": "0.7.43",
|
||||
"flexsearch": "0.8.205",
|
||||
"katex": "0.16.22",
|
||||
"lodash": "4.17.21",
|
||||
"mermaid": "11.7.0",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import groupBy from "lodash/groupBy.js"
|
||||
import truncate from "lodash/truncate.js"
|
||||
import Document from "flexsearch/dist/module/document.js"
|
||||
import { Document, Charset } from "flexsearch"
|
||||
import { Validator } from "@cfworker/json-schema"
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
|
@ -55,7 +55,8 @@ function init(input, searchConfig) {
|
|||
input.removeEventListener("focus", init)
|
||||
|
||||
const indexCfgDefaults = {
|
||||
tokenize: "forward"
|
||||
tokenize: "forward",
|
||||
encoder: Charset.LatinBalance
|
||||
}
|
||||
const indexCfg = searchConfig.indexConfig ? searchConfig.indexConfig : indexCfgDefaults
|
||||
const dataUrl = searchConfig.dataFile
|
||||
|
@ -63,7 +64,7 @@ function init(input, searchConfig) {
|
|||
indexCfg.document = {
|
||||
key: "id",
|
||||
index: ["title", "content", "description"],
|
||||
store: ["title", "href", "parent", "description"]
|
||||
store: ["title", "href", "parent", "content", "description"]
|
||||
}
|
||||
|
||||
const index = new Document(indexCfg)
|
||||
|
@ -79,7 +80,14 @@ function init(input, searchConfig) {
|
|||
function search(input, results, searchConfig) {
|
||||
const searchCfg = {
|
||||
enrich: true,
|
||||
limit: 5
|
||||
limit: 5,
|
||||
highlight: {
|
||||
template: "<b>$1</b>",
|
||||
boundary: {
|
||||
before: 10,
|
||||
after: 20
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (results.firstChild) {
|
||||
|
@ -157,10 +165,23 @@ function createLinks(pages, target, showDesc) {
|
|||
if (showDesc === true) {
|
||||
const desc = a.appendChild(document.createElement("span"))
|
||||
desc.classList.add("gdoc-search__entry--description")
|
||||
desc.textContent = truncate(page.description, {
|
||||
length: 55,
|
||||
separator: " "
|
||||
})
|
||||
|
||||
if (page.highlight) {
|
||||
const parser = new DOMParser()
|
||||
const doc = parser.parseFromString(
|
||||
truncate(page.highlight, {
|
||||
length: 55,
|
||||
separator: " "
|
||||
}),
|
||||
"text/html"
|
||||
)
|
||||
desc.innerHTML = doc.body.innerHTML
|
||||
} else {
|
||||
desc.textContent = truncate(page.description, {
|
||||
length: 55,
|
||||
separator: " "
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (target) {
|
||||
|
@ -206,6 +227,11 @@ function flattenHits(results) {
|
|||
for (const page of field.result) {
|
||||
if (!map.has(page.doc.href)) {
|
||||
map.set(page.doc.href, true)
|
||||
|
||||
if (page.highlight) {
|
||||
page.doc.highlight = page.highlight
|
||||
}
|
||||
|
||||
items.push(page.doc)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue