1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-11-24 07:30:12 +01:00

Refactored search pipeline configuration

This commit is contained in:
squidfunk 2020-03-04 21:42:19 +01:00
parent af9505293b
commit dbb5b2e8c3
12 changed files with 26 additions and 35 deletions

View File

@ -52,13 +52,20 @@ export interface SearchIndexDocument {
text: string /* Document text */
}
/* ------------------------------------------------------------------------- */
/**
* Search index pipeline function
*/
export type SearchIndexPipelineFn =
| "stemmer" /* Stemmer */
| "stopWordFilter" /* Stop word filter */
| "trimmer" /* Trimmer */
/**
* Search index pipeline
*/
export interface SearchIndexPipeline {
trimmer: boolean /* Add trimmer to pipeline */
stopwords: boolean /* Add stopword filter to pipeline */
}
export type SearchIndexPipeline = SearchIndexPipelineFn[]
/* ------------------------------------------------------------------------- */
@ -129,17 +136,12 @@ export class SearchIndex {
/* If no index was given, create it */
if (typeof index === "undefined") {
this.index = lunr(function() {
pipeline = pipeline || {
trimmer: true,
stopwords: true
}
pipeline = pipeline || ["trimmer", "stopWordFilter"]
/* Remove stemmer, as it cripples search experience */
/* Set up pipeline according to configuration */
this.pipeline.reset()
if (pipeline.trimmer)
this.pipeline.add(lunr.trimmer)
if (pipeline.stopwords)
this.pipeline.add(lunr.stopWordFilter)
for (const fn of pipeline)
this.pipeline.add(lunr[fn])
/* Set up alternate search languages */
if (config.lang.length === 1 && config.lang[0] !== "en") {

View File

@ -32,8 +32,7 @@
"meta.comments": "التعليقات",
"meta.source": "المصدر",
"search.language": "",
"search.pipeline.stopwords": false,
"search.pipeline.trimmer": false,
"search.pipeline": "",
"search.placeholder": "بحث",
"search.result.placeholder": "اكتب لبدء البحث",
"search.result.none": "لا توجد نتائج",

View File

@ -32,8 +32,7 @@
"meta.comments": "Comments",
"meta.source": "Source",
"search.language": "en",
"search.pipeline.stopwords": true,
"search.pipeline.trimmer": true,
"search.pipeline": "trimmer, stopWordFilter",
"search.placeholder": "Search",
"search.result.placeholder": "Type to start searching",
"search.result.none": "No matching documents",

View File

@ -31,8 +31,7 @@
"meta.comments": "Kommentaarid",
"meta.source": "Lähtekood",
"search.language": "",
"search.pipeline.stopwords": false,
"search.pipeline.trimmer": false,
"search.pipeline": "",
"search.placeholder": "Otsi",
"search.result.placeholder": "Otsimiseks kirjuta siia",
"search.result.none": "Otsingule ei leitud ühtegi vastet",

View File

@ -32,8 +32,7 @@
"meta.comments": "نظرات",
"meta.source": "منبع",
"search.language": "",
"search.pipeline.stopwords": false,
"search.pipeline.trimmer": false,
"search.pipeline": "",
"search.placeholder": "جستجو",
"search.result.placeholder": "برای شروع جستجو تایپ کنید",
"search.result.none": "سندی یافت نشد",

View File

@ -31,8 +31,7 @@
"meta.comments": "Σχόλια",
"meta.source": "Πηγή",
"search.language": "",
"search.pipeline.stopwords": false,
"search.pipeline.trimmer": false,
"search.pipeline": "",
"search.placeholder": "Αναζήτηση",
"search.result.placeholder": "Πληκτρολογήστε για να αρχίσει η αναζήτηση",
"search.result.none": "Δε βρέθηκαν αντίστοιχα αρχεία",

View File

@ -32,8 +32,7 @@
"meta.comments": "הערות",
"meta.source": "מָקוֹר",
"search.language": "",
"search.pipeline.stopwords": false,
"search.pipeline.trimmer": false,
"search.pipeline": "",
"search.placeholder": "לחפש",
"search.result.placeholder": "הקלד כדי להתחיל לחפש",
"search.result.none": "אין מסמכים תואמים",

View File

@ -31,8 +31,7 @@
"meta.comments": "टिप्पणियाँ",
"meta.source": "स्रोत",
"search.language": "",
"search.pipeline.stopwords": false,
"search.pipeline.trimmer": false,
"search.pipeline": "",
"search.placeholder": "खोज",
"search.result.placeholder": "खोज शुरू करने के लिए टाइप करें",
"search.result.none": "कोई मिलान डॉक्यूमेंट नहीं",

View File

@ -31,8 +31,7 @@
"meta.comments": "Komentari",
"meta.source": "Izvor",
"search.language": "",
"search.pipeline.stopwords": false,
"search.pipeline.trimmer": false,
"search.pipeline": "",
"search.placeholder": "Pretraživanje",
"search.result.placeholder": "Unesite pojam pretraživanja",
"search.result.none": "Ništa nije pronađeno",

View File

@ -31,8 +31,7 @@
"meta.comments": "Komentar",
"meta.source": "Sumber",
"search.language": "",
"search.pipeline.stopwords": false,
"search.pipeline.trimmer": false,
"search.pipeline": "",
"search.placeholder": "Cari",
"search.result.placeholder": "Ketik untuk mulai pencarian",
"search.result.none": "Tidak ada dokumen yang sesuai",

View File

@ -31,8 +31,7 @@
"meta.comments": "Komentarze",
"meta.source": "Kod źródłowy",
"search.language": "",
"search.pipeline.stopwords": false,
"search.pipeline.trimmer": false,
"search.pipeline": "",
"search.placeholder": "Szukaj",
"search.result.placeholder": "Zacznij pisać, aby szukać",
"search.result.none": "Brak wyników wyszukiwania",

View File

@ -31,8 +31,7 @@
"meta.comments": "Коментари",
"meta.source": "Извор",
"search.language": "",
"search.pipeline.stopwords": false,
"search.pipeline.trimmer": false,
"search.pipeline": "",
"search.placeholder": "Претрага",
"search.result.placeholder": "Унесите појам претраге",
"search.result.none": "Нису пронађени документи",