mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Fixed search when query contains colon after non-field
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -212,7 +212,7 @@
|
|||||||
"base": base_url,
|
"base": base_url,
|
||||||
"features": features,
|
"features": features,
|
||||||
"translations": {},
|
"translations": {},
|
||||||
"search": "assets/javascripts/workers/search.e5c33ebb.min.js" | url
|
"search": "assets/javascripts/workers/search.db81ec45.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 }) -%}
|
||||||
|
|||||||
@@ -70,7 +70,20 @@ export function transformSearchQuery(
|
|||||||
|
|
||||||
/* Extract and tokenize term from lexeme */
|
/* Extract and tokenize term from lexeme */
|
||||||
for (const { type, str: term, start, end } of lexer.lexemes)
|
for (const { type, str: term, start, end } of lexer.lexemes)
|
||||||
if (type === "TERM")
|
switch (type) {
|
||||||
|
|
||||||
|
/* Hack: remove colon - see https://bit.ly/3wD3T3I */
|
||||||
|
case "FIELD":
|
||||||
|
if (!["title", "text", "tags"].includes(term))
|
||||||
|
part = [
|
||||||
|
part.slice(0, end),
|
||||||
|
" ",
|
||||||
|
part.slice(end + 1)
|
||||||
|
].join("")
|
||||||
|
break
|
||||||
|
|
||||||
|
/* Tokenize term */
|
||||||
|
case "TERM":
|
||||||
split(term, lunr.tokenizer.separator, (...range) => {
|
split(term, lunr.tokenizer.separator, (...range) => {
|
||||||
terms.push([
|
terms.push([
|
||||||
part.slice(0, start),
|
part.slice(0, start),
|
||||||
@@ -78,6 +91,7 @@ export function transformSearchQuery(
|
|||||||
part.slice(end)
|
part.slice(end)
|
||||||
].join(""))
|
].join(""))
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/* Return terms */
|
/* Return terms */
|
||||||
return terms
|
return terms
|
||||||
|
|||||||
Reference in New Issue
Block a user