mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Refactored search pipeline configuration
This commit is contained in:
parent
af9505293b
commit
dbb5b2e8c3
@ -52,13 +52,20 @@ export interface SearchIndexDocument {
|
|||||||
text: string /* Document text */
|
text: string /* Document text */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search index pipeline function
|
||||||
|
*/
|
||||||
|
export type SearchIndexPipelineFn =
|
||||||
|
| "stemmer" /* Stemmer */
|
||||||
|
| "stopWordFilter" /* Stop word filter */
|
||||||
|
| "trimmer" /* Trimmer */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search index pipeline
|
* Search index pipeline
|
||||||
*/
|
*/
|
||||||
export interface SearchIndexPipeline {
|
export type SearchIndexPipeline = SearchIndexPipelineFn[]
|
||||||
trimmer: boolean /* Add trimmer to pipeline */
|
|
||||||
stopwords: boolean /* Add stopword filter to pipeline */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
@ -129,17 +136,12 @@ export class SearchIndex {
|
|||||||
/* If no index was given, create it */
|
/* If no index was given, create it */
|
||||||
if (typeof index === "undefined") {
|
if (typeof index === "undefined") {
|
||||||
this.index = lunr(function() {
|
this.index = lunr(function() {
|
||||||
pipeline = pipeline || {
|
pipeline = pipeline || ["trimmer", "stopWordFilter"]
|
||||||
trimmer: true,
|
|
||||||
stopwords: true
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remove stemmer, as it cripples search experience */
|
/* Set up pipeline according to configuration */
|
||||||
this.pipeline.reset()
|
this.pipeline.reset()
|
||||||
if (pipeline.trimmer)
|
for (const fn of pipeline)
|
||||||
this.pipeline.add(lunr.trimmer)
|
this.pipeline.add(lunr[fn])
|
||||||
if (pipeline.stopwords)
|
|
||||||
this.pipeline.add(lunr.stopWordFilter)
|
|
||||||
|
|
||||||
/* Set up alternate search languages */
|
/* Set up alternate search languages */
|
||||||
if (config.lang.length === 1 && config.lang[0] !== "en") {
|
if (config.lang.length === 1 && config.lang[0] !== "en") {
|
||||||
|
@ -32,8 +32,7 @@
|
|||||||
"meta.comments": "التعليقات",
|
"meta.comments": "التعليقات",
|
||||||
"meta.source": "المصدر",
|
"meta.source": "المصدر",
|
||||||
"search.language": "",
|
"search.language": "",
|
||||||
"search.pipeline.stopwords": false,
|
"search.pipeline": "",
|
||||||
"search.pipeline.trimmer": false,
|
|
||||||
"search.placeholder": "بحث",
|
"search.placeholder": "بحث",
|
||||||
"search.result.placeholder": "اكتب لبدء البحث",
|
"search.result.placeholder": "اكتب لبدء البحث",
|
||||||
"search.result.none": "لا توجد نتائج",
|
"search.result.none": "لا توجد نتائج",
|
||||||
|
@ -32,8 +32,7 @@
|
|||||||
"meta.comments": "Comments",
|
"meta.comments": "Comments",
|
||||||
"meta.source": "Source",
|
"meta.source": "Source",
|
||||||
"search.language": "en",
|
"search.language": "en",
|
||||||
"search.pipeline.stopwords": true,
|
"search.pipeline": "trimmer, stopWordFilter",
|
||||||
"search.pipeline.trimmer": true,
|
|
||||||
"search.placeholder": "Search",
|
"search.placeholder": "Search",
|
||||||
"search.result.placeholder": "Type to start searching",
|
"search.result.placeholder": "Type to start searching",
|
||||||
"search.result.none": "No matching documents",
|
"search.result.none": "No matching documents",
|
||||||
|
@ -31,8 +31,7 @@
|
|||||||
"meta.comments": "Kommentaarid",
|
"meta.comments": "Kommentaarid",
|
||||||
"meta.source": "Lähtekood",
|
"meta.source": "Lähtekood",
|
||||||
"search.language": "",
|
"search.language": "",
|
||||||
"search.pipeline.stopwords": false,
|
"search.pipeline": "",
|
||||||
"search.pipeline.trimmer": false,
|
|
||||||
"search.placeholder": "Otsi",
|
"search.placeholder": "Otsi",
|
||||||
"search.result.placeholder": "Otsimiseks kirjuta siia",
|
"search.result.placeholder": "Otsimiseks kirjuta siia",
|
||||||
"search.result.none": "Otsingule ei leitud ühtegi vastet",
|
"search.result.none": "Otsingule ei leitud ühtegi vastet",
|
||||||
|
@ -32,8 +32,7 @@
|
|||||||
"meta.comments": "نظرات",
|
"meta.comments": "نظرات",
|
||||||
"meta.source": "منبع",
|
"meta.source": "منبع",
|
||||||
"search.language": "",
|
"search.language": "",
|
||||||
"search.pipeline.stopwords": false,
|
"search.pipeline": "",
|
||||||
"search.pipeline.trimmer": false,
|
|
||||||
"search.placeholder": "جستجو",
|
"search.placeholder": "جستجو",
|
||||||
"search.result.placeholder": "برای شروع جستجو تایپ کنید",
|
"search.result.placeholder": "برای شروع جستجو تایپ کنید",
|
||||||
"search.result.none": "سندی یافت نشد",
|
"search.result.none": "سندی یافت نشد",
|
||||||
|
@ -31,8 +31,7 @@
|
|||||||
"meta.comments": "Σχόλια",
|
"meta.comments": "Σχόλια",
|
||||||
"meta.source": "Πηγή",
|
"meta.source": "Πηγή",
|
||||||
"search.language": "",
|
"search.language": "",
|
||||||
"search.pipeline.stopwords": false,
|
"search.pipeline": "",
|
||||||
"search.pipeline.trimmer": false,
|
|
||||||
"search.placeholder": "Αναζήτηση",
|
"search.placeholder": "Αναζήτηση",
|
||||||
"search.result.placeholder": "Πληκτρολογήστε για να αρχίσει η αναζήτηση",
|
"search.result.placeholder": "Πληκτρολογήστε για να αρχίσει η αναζήτηση",
|
||||||
"search.result.none": "Δε βρέθηκαν αντίστοιχα αρχεία",
|
"search.result.none": "Δε βρέθηκαν αντίστοιχα αρχεία",
|
||||||
|
@ -32,8 +32,7 @@
|
|||||||
"meta.comments": "הערות",
|
"meta.comments": "הערות",
|
||||||
"meta.source": "מָקוֹר",
|
"meta.source": "מָקוֹר",
|
||||||
"search.language": "",
|
"search.language": "",
|
||||||
"search.pipeline.stopwords": false,
|
"search.pipeline": "",
|
||||||
"search.pipeline.trimmer": false,
|
|
||||||
"search.placeholder": "לחפש",
|
"search.placeholder": "לחפש",
|
||||||
"search.result.placeholder": "הקלד כדי להתחיל לחפש",
|
"search.result.placeholder": "הקלד כדי להתחיל לחפש",
|
||||||
"search.result.none": "אין מסמכים תואמים",
|
"search.result.none": "אין מסמכים תואמים",
|
||||||
|
@ -31,8 +31,7 @@
|
|||||||
"meta.comments": "टिप्पणियाँ",
|
"meta.comments": "टिप्पणियाँ",
|
||||||
"meta.source": "स्रोत",
|
"meta.source": "स्रोत",
|
||||||
"search.language": "",
|
"search.language": "",
|
||||||
"search.pipeline.stopwords": false,
|
"search.pipeline": "",
|
||||||
"search.pipeline.trimmer": false,
|
|
||||||
"search.placeholder": "खोज",
|
"search.placeholder": "खोज",
|
||||||
"search.result.placeholder": "खोज शुरू करने के लिए टाइप करें",
|
"search.result.placeholder": "खोज शुरू करने के लिए टाइप करें",
|
||||||
"search.result.none": "कोई मिलान डॉक्यूमेंट नहीं",
|
"search.result.none": "कोई मिलान डॉक्यूमेंट नहीं",
|
||||||
|
@ -31,8 +31,7 @@
|
|||||||
"meta.comments": "Komentari",
|
"meta.comments": "Komentari",
|
||||||
"meta.source": "Izvor",
|
"meta.source": "Izvor",
|
||||||
"search.language": "",
|
"search.language": "",
|
||||||
"search.pipeline.stopwords": false,
|
"search.pipeline": "",
|
||||||
"search.pipeline.trimmer": false,
|
|
||||||
"search.placeholder": "Pretraživanje",
|
"search.placeholder": "Pretraživanje",
|
||||||
"search.result.placeholder": "Unesite pojam pretraživanja",
|
"search.result.placeholder": "Unesite pojam pretraživanja",
|
||||||
"search.result.none": "Ništa nije pronađeno",
|
"search.result.none": "Ništa nije pronađeno",
|
||||||
|
@ -31,8 +31,7 @@
|
|||||||
"meta.comments": "Komentar",
|
"meta.comments": "Komentar",
|
||||||
"meta.source": "Sumber",
|
"meta.source": "Sumber",
|
||||||
"search.language": "",
|
"search.language": "",
|
||||||
"search.pipeline.stopwords": false,
|
"search.pipeline": "",
|
||||||
"search.pipeline.trimmer": false,
|
|
||||||
"search.placeholder": "Cari",
|
"search.placeholder": "Cari",
|
||||||
"search.result.placeholder": "Ketik untuk mulai pencarian",
|
"search.result.placeholder": "Ketik untuk mulai pencarian",
|
||||||
"search.result.none": "Tidak ada dokumen yang sesuai",
|
"search.result.none": "Tidak ada dokumen yang sesuai",
|
||||||
|
@ -31,8 +31,7 @@
|
|||||||
"meta.comments": "Komentarze",
|
"meta.comments": "Komentarze",
|
||||||
"meta.source": "Kod źródłowy",
|
"meta.source": "Kod źródłowy",
|
||||||
"search.language": "",
|
"search.language": "",
|
||||||
"search.pipeline.stopwords": false,
|
"search.pipeline": "",
|
||||||
"search.pipeline.trimmer": false,
|
|
||||||
"search.placeholder": "Szukaj",
|
"search.placeholder": "Szukaj",
|
||||||
"search.result.placeholder": "Zacznij pisać, aby szukać",
|
"search.result.placeholder": "Zacznij pisać, aby szukać",
|
||||||
"search.result.none": "Brak wyników wyszukiwania",
|
"search.result.none": "Brak wyników wyszukiwania",
|
||||||
|
@ -31,8 +31,7 @@
|
|||||||
"meta.comments": "Коментари",
|
"meta.comments": "Коментари",
|
||||||
"meta.source": "Извор",
|
"meta.source": "Извор",
|
||||||
"search.language": "",
|
"search.language": "",
|
||||||
"search.pipeline.stopwords": false,
|
"search.pipeline": "",
|
||||||
"search.pipeline.trimmer": false,
|
|
||||||
"search.placeholder": "Претрага",
|
"search.placeholder": "Претрага",
|
||||||
"search.result.placeholder": "Унесите појам претраге",
|
"search.result.placeholder": "Унесите појам претраге",
|
||||||
"search.result.none": "Нису пронађени документи",
|
"search.result.none": "Нису пронађени документи",
|
||||||
|
Loading…
Reference in New Issue
Block a user