prefix: true, // Allow partial matches
processTerm: (term, _fieldName) => term.length < 3 ? null : term.toLowerCase()
},
- },
- querystring: '', // The search query
+ }, querystring: '', // The search query
query: '', // The search query
+ results:[],
+ resultCount:0,
medialibrary: '', // Holds URL of the media library that is passed in from the component
async init() {
return `<a href="${URL}" class="${classes}" ${attributes}>${result.title}</a>`;
},
- doSearch(){
- this.query=this.querystring;
- },
-
- get results() {
- if (this.query.length < 3) {
- return [];
+ doSearch() {
+ this.query = this.querystring;
+ this.results = [];
+ if (this.query.length >= 3) {
+ this.results = this.miniSearch.search(this.query);
+ if (this.results.length === 1) {
+ this.resultCount = '1 résultat'
+ } else {
+ this.resultCount = this.results.length + ' résultats';
+ }
+ } else {
+ this.resultCount = "Veuillez taper au moins 3 caractères";
}
-
- return this.miniSearch.search(this.query);
- },
-
- get showResults() {
- return false;
- },
-
- get resultCount() {
- if (this.query.length < 3) {
- return "Veuillez taper au moins 3 caractères";
- }
- if (this.results.length === 1) {
- return '1 résultat'
- }
-
- return `${this.results.length} résultats`;
},
});