mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-11-12 10:00:52 +01:00
Added support for lunr-languages
This commit is contained in:
parent
1fdb65b88f
commit
018e38e9ac
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
@ -4,11 +4,5 @@
|
||||
{% import "partials/language/" + config.theme.language + ".html" as lang %}
|
||||
{% import "partials/language/en.html" as fallback %}
|
||||
{% macro t(key) %}{{ {
|
||||
"direction": config.theme.direction,
|
||||
"search.language": (
|
||||
config.extra.search | default({})
|
||||
).language,
|
||||
"search.tokenizer": (
|
||||
config.extra.search | default({})
|
||||
).tokenizer | default("", true),
|
||||
"direction": config.theme.direction
|
||||
}[key] or lang.t(key) or fallback.t(key) }}{% endmacro %}
|
||||
|
@ -70,7 +70,8 @@ import {
|
||||
watchWorker,
|
||||
setToggle,
|
||||
getElements,
|
||||
watchMedia
|
||||
watchMedia,
|
||||
translate
|
||||
} from "./utilities"
|
||||
import {
|
||||
PackerMessage,
|
||||
|
@ -137,6 +137,13 @@ export class SearchIndex {
|
||||
if (pipeline.stopwords)
|
||||
this.pipeline.add(lunr.stopWordFilter)
|
||||
|
||||
/* Set up alternate search languages */
|
||||
if (config.lang.length === 1 && config.lang[0] !== "en") {
|
||||
this.use((lunr as any)[config.lang[0]])
|
||||
} else if (config.lang.length > 1) {
|
||||
this.use((lunr as any).multiLanguage(...config.lang))
|
||||
}
|
||||
|
||||
/* Setup fields and reference */
|
||||
this.field("title", { boost: 10 })
|
||||
this.field("text")
|
||||
|
@ -28,11 +28,5 @@
|
||||
|
||||
<!-- Re-export translations -->
|
||||
{% macro t(key) %}{{ {
|
||||
"direction": config.theme.direction,
|
||||
"search.language": (
|
||||
config.extra.search | default({})
|
||||
).language,
|
||||
"search.tokenizer": (
|
||||
config.extra.search | default({})
|
||||
).tokenizer | default("", true),
|
||||
"direction": config.theme.direction
|
||||
}[key] or lang.t(key) or fallback.t(key) }}{% endmacro %}
|
||||
|
Loading…
Reference in New Issue
Block a user