mirror of
https://github.com/vale981/Vulcan
synced 2025-03-09 04:16:37 -04:00
24 lines
No EOL
789 B
JavaScript
24 lines
No EOL
789 B
JavaScript
import Telescope from 'meteor/nova:lib';
|
|
import escapeStringRegexp from 'escape-string-regexp';
|
|
|
|
function addSearchQueryParameter (parameters, terms) {
|
|
if(!!terms.query) {
|
|
|
|
const query = escapeStringRegexp(terms.query);
|
|
|
|
var parameters = Telescope.utils.deepExtend(true, parameters, {
|
|
selector: {
|
|
$or: [
|
|
{title: {$regex: query, $options: 'i'}},
|
|
{url: {$regex: query, $options: 'i'}},
|
|
// note: we cannot search the body field because it's not published
|
|
// to the client. If we did, we'd get different result sets on
|
|
// client and server
|
|
{excerpt: {$regex: query, $options: 'i'}}
|
|
]
|
|
}
|
|
});
|
|
}
|
|
return parameters;
|
|
}
|
|
Telescope.callbacks.add("posts.parameters", addSearchQueryParameter); |