Removed deprecated prebuilt index support

This commit is contained in:
squidfunk 2021-11-13 09:09:25 +01:00
parent 8eca83d8bf
commit a0ea9632da
7 changed files with 48 additions and 57 deletions

View File

@ -190,7 +190,7 @@
"base": base_url,
"features": features,
"translations": {},
"search": "assets/javascripts/workers/search.8397ff9e.min.js" | url,
"search": "assets/javascripts/workers/search.01824240.min.js" | url,
"version": config.extra.version or None
} -%}
{%- set translations = app.translations -%}
@ -217,7 +217,7 @@
</script>
{% endblock %}
{% block scripts %}
<script src="{{ 'assets/javascripts/bundle.333da091.min.js' | url }}"></script>
<script src="{{ 'assets/javascripts/bundle.ccba565e.min.js' | url }}"></script>
{% for path in config["extra_javascript"] %}
<script src="{{ path | url }}"></script>
{% endfor %}

View File

@ -68,7 +68,6 @@ export interface SearchIndexDocument {
export interface SearchIndex {
config: SearchIndexConfig /* Search index configuration */
docs: SearchIndexDocument[] /* Search index documents */
index?: object /* Prebuilt index */
options: SearchOptions /* Search options */
}
@ -162,7 +161,7 @@ export class Search {
*
* @param data - Search index
*/
public constructor({ config, docs, index, options }: SearchIndex) {
public constructor({ config, docs, options }: SearchIndex) {
this.options = options
/* Set up document map and highlighter factory */
@ -172,8 +171,7 @@ export class Search {
/* Set separator for tokenizer */
lunr.tokenizer.separator = new RegExp(config.separator)
/* If no index was given, create it */
if (typeof index === "undefined") {
/* Create search index */
this.index = lunr(function () {
/* Set up multi-language support */
@ -209,11 +207,6 @@ export class Search {
for (const doc of docs)
this.add(doc)
})
/* Handle prebuilt index */
} else {
this.index = lunr.Index.load(index)
}
}
/**

View File

@ -58,9 +58,7 @@ export type SearchWorker = WorkerHandler<SearchMessage>
*
* @returns Search index
*/
function setupSearchIndex(
{ config, docs, index }: SearchIndex
): SearchIndex {
function setupSearchIndex({ config, docs }: SearchIndex): SearchIndex {
/* Override default language with value from translation */
if (config.lang.length === 1 && config.lang[0] === "en")
@ -84,7 +82,7 @@ function setupSearchIndex(
}
/* Return search index after defaulting */
return { config, docs, index, options }
return { config, docs, options }
}
/* ----------------------------------------------------------------------------