mirror of
https://github.com/PeWu/topola-viewer.git
synced 2026-08-02 09:01:48 +00:00
Support different languages in search (#21)
This commit is contained in:
5
package-lock.json
generated
5
package-lock.json
generated
@@ -11145,6 +11145,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz",
|
"resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz",
|
||||||
"integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow=="
|
"integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow=="
|
||||||
},
|
},
|
||||||
|
"lunr-languages": {
|
||||||
|
"version": "1.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lunr-languages/-/lunr-languages-1.4.0.tgz",
|
||||||
|
"integrity": "sha512-YWfZDExJN/MJEVE/DbM4AuVRLsqeHi+q3wmECMsWjGIOkd5mr9DUNos7fv8f5do9VLRMYXIzFjn+N4+KPI9pQA=="
|
||||||
|
},
|
||||||
"make-dir": {
|
"make-dir": {
|
||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz",
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
"js-cookie": "^2.2.1",
|
"js-cookie": "^2.2.1",
|
||||||
"jspdf": "^1.5.3",
|
"jspdf": "^1.5.3",
|
||||||
"lunr": "^2.3.6",
|
"lunr": "^2.3.6",
|
||||||
|
"lunr-languages": "^1.4.0",
|
||||||
"md5": "^2.2.1",
|
"md5": "^2.2.1",
|
||||||
"parse-gedcom": "^1.0.5",
|
"parse-gedcom": "^1.0.5",
|
||||||
"query-string": "^5.1.1",
|
"query-string": "^5.1.1",
|
||||||
|
|||||||
@@ -3,6 +3,14 @@ import naturalSort from 'javascript-natural-sort';
|
|||||||
import {idToFamMap, idToIndiMap} from '../util/gedcom_util';
|
import {idToFamMap, idToIndiMap} from '../util/gedcom_util';
|
||||||
import {JsonFam, JsonGedcomData, JsonIndi} from 'topola';
|
import {JsonFam, JsonGedcomData, JsonIndi} from 'topola';
|
||||||
|
|
||||||
|
// TODO: Add type declarations and use import instead of require.
|
||||||
|
require('lunr-languages/lunr.stemmer.support')(lunr);
|
||||||
|
require('lunr-languages/lunr.multi')(lunr);
|
||||||
|
require('lunr-languages/lunr.de')(lunr);
|
||||||
|
require('lunr-languages/lunr.fr')(lunr);
|
||||||
|
require('lunr-languages/lunr.it')(lunr);
|
||||||
|
require('lunr-languages/lunr.ru')(lunr);
|
||||||
|
|
||||||
const MAX_RESULTS = 8;
|
const MAX_RESULTS = 8;
|
||||||
|
|
||||||
export interface SearchResult {
|
export interface SearchResult {
|
||||||
@@ -58,6 +66,7 @@ class LunrSearchIndex implements SearchIndex {
|
|||||||
initialize() {
|
initialize() {
|
||||||
const self = this;
|
const self = this;
|
||||||
this.index = lunr(function() {
|
this.index = lunr(function() {
|
||||||
|
this.use((lunr as any).multiLanguage('de', 'en', 'fr', 'it', 'ru'));
|
||||||
this.ref('id');
|
this.ref('id');
|
||||||
this.field('id');
|
this.field('id');
|
||||||
this.field('name', {boost: 10});
|
this.field('name', {boost: 10});
|
||||||
|
|||||||
Reference in New Issue
Block a user