Fixed search stuck in initializing when tags are used

This commit is contained in:
squidfunk 2022-06-22 07:50:43 +02:00
parent e86896645b
commit e3ce3dbc25
4 changed files with 9 additions and 6 deletions

View File

@ -187,7 +187,7 @@
"base": base_url, "base": base_url,
"features": features, "features": features,
"translations": {}, "translations": {},
"search": "assets/javascripts/workers/search.62afc64d.min.js" | url "search": "assets/javascripts/workers/search.b97dbffb.min.js" | url
} -%} } -%}
{%- if config.extra.version -%} {%- if config.extra.version -%}
{%- set _ = app.update({ "version": config.extra.version }) -%} {%- set _ = app.update({ "version": config.extra.version }) -%}

View File

@ -206,7 +206,10 @@ export class Search {
this.field("text") this.field("text")
this.field("tags", { boost: 1e6, extractor: doc => { this.field("tags", { boost: 1e6, extractor: doc => {
const { tags = [] } = doc as SearchDocument const { tags = [] } = doc as SearchDocument
return tags.flatMap(tag => lunr.tokenizer(tag)) return tags.reduce((list, tag) => [
...list,
...lunr.tokenizer(tag)
], [] as lunr.Token[])
} }) } })
/* Index documents */ /* Index documents */