mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Removed deprecated prebuilt index support
This commit is contained in:
parent
8eca83d8bf
commit
a0ea9632da
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -190,7 +190,7 @@
|
|||||||
"base": base_url,
|
"base": base_url,
|
||||||
"features": features,
|
"features": features,
|
||||||
"translations": {},
|
"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
|
"version": config.extra.version or None
|
||||||
} -%}
|
} -%}
|
||||||
{%- set translations = app.translations -%}
|
{%- set translations = app.translations -%}
|
||||||
@ -217,7 +217,7 @@
|
|||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block scripts %}
|
{% 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"] %}
|
{% for path in config["extra_javascript"] %}
|
||||||
<script src="{{ path | url }}"></script>
|
<script src="{{ path | url }}"></script>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -68,7 +68,6 @@ export interface SearchIndexDocument {
|
|||||||
export interface SearchIndex {
|
export interface SearchIndex {
|
||||||
config: SearchIndexConfig /* Search index configuration */
|
config: SearchIndexConfig /* Search index configuration */
|
||||||
docs: SearchIndexDocument[] /* Search index documents */
|
docs: SearchIndexDocument[] /* Search index documents */
|
||||||
index?: object /* Prebuilt index */
|
|
||||||
options: SearchOptions /* Search options */
|
options: SearchOptions /* Search options */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +161,7 @@ export class Search {
|
|||||||
*
|
*
|
||||||
* @param data - Search index
|
* @param data - Search index
|
||||||
*/
|
*/
|
||||||
public constructor({ config, docs, index, options }: SearchIndex) {
|
public constructor({ config, docs, options }: SearchIndex) {
|
||||||
this.options = options
|
this.options = options
|
||||||
|
|
||||||
/* Set up document map and highlighter factory */
|
/* Set up document map and highlighter factory */
|
||||||
@ -172,48 +171,42 @@ export class Search {
|
|||||||
/* Set separator for tokenizer */
|
/* Set separator for tokenizer */
|
||||||
lunr.tokenizer.separator = new RegExp(config.separator)
|
lunr.tokenizer.separator = new RegExp(config.separator)
|
||||||
|
|
||||||
/* If no index was given, create it */
|
/* Create search index */
|
||||||
if (typeof index === "undefined") {
|
this.index = lunr(function () {
|
||||||
this.index = lunr(function () {
|
|
||||||
|
|
||||||
/* Set up multi-language support */
|
/* Set up multi-language support */
|
||||||
if (config.lang.length === 1 && config.lang[0] !== "en") {
|
if (config.lang.length === 1 && config.lang[0] !== "en") {
|
||||||
this.use((lunr as any)[config.lang[0]])
|
this.use((lunr as any)[config.lang[0]])
|
||||||
} else if (config.lang.length > 1) {
|
} else if (config.lang.length > 1) {
|
||||||
this.use((lunr as any).multiLanguage(...config.lang))
|
this.use((lunr as any).multiLanguage(...config.lang))
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Compute functions to be removed from the pipeline */
|
||||||
|
const fns = difference([
|
||||||
|
"trimmer", "stopWordFilter", "stemmer"
|
||||||
|
], options.pipeline)
|
||||||
|
|
||||||
|
/* Remove functions from the pipeline for registered languages */
|
||||||
|
for (const lang of config.lang.map(language => (
|
||||||
|
language === "en" ? lunr : (lunr as any)[language]
|
||||||
|
))) {
|
||||||
|
for (const fn of fns) {
|
||||||
|
this.pipeline.remove(lang[fn])
|
||||||
|
this.searchPipeline.remove(lang[fn])
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Compute functions to be removed from the pipeline */
|
/* Set up reference */
|
||||||
const fns = difference([
|
this.ref("location")
|
||||||
"trimmer", "stopWordFilter", "stemmer"
|
|
||||||
], options.pipeline)
|
|
||||||
|
|
||||||
/* Remove functions from the pipeline for registered languages */
|
/* Set up fields */
|
||||||
for (const lang of config.lang.map(language => (
|
this.field("title", { boost: 1e3 })
|
||||||
language === "en" ? lunr : (lunr as any)[language]
|
this.field("text")
|
||||||
))) {
|
|
||||||
for (const fn of fns) {
|
|
||||||
this.pipeline.remove(lang[fn])
|
|
||||||
this.searchPipeline.remove(lang[fn])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set up reference */
|
/* Index documents */
|
||||||
this.ref("location")
|
for (const doc of docs)
|
||||||
|
this.add(doc)
|
||||||
/* Set up fields */
|
})
|
||||||
this.field("title", { boost: 1e3 })
|
|
||||||
this.field("text")
|
|
||||||
|
|
||||||
/* Index documents */
|
|
||||||
for (const doc of docs)
|
|
||||||
this.add(doc)
|
|
||||||
})
|
|
||||||
|
|
||||||
/* Handle prebuilt index */
|
|
||||||
} else {
|
|
||||||
this.index = lunr.Index.load(index)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,9 +58,7 @@ export type SearchWorker = WorkerHandler<SearchMessage>
|
|||||||
*
|
*
|
||||||
* @returns Search index
|
* @returns Search index
|
||||||
*/
|
*/
|
||||||
function setupSearchIndex(
|
function setupSearchIndex({ config, docs }: SearchIndex): SearchIndex {
|
||||||
{ config, docs, index }: SearchIndex
|
|
||||||
): SearchIndex {
|
|
||||||
|
|
||||||
/* Override default language with value from translation */
|
/* Override default language with value from translation */
|
||||||
if (config.lang.length === 1 && config.lang[0] === "en")
|
if (config.lang.length === 1 && config.lang[0] === "en")
|
||||||
@ -84,7 +82,7 @@ function setupSearchIndex(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Return search index after defaulting */
|
/* Return search index after defaulting */
|
||||||
return { config, docs, index, options }
|
return { config, docs, options }
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
/* ----------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user