Skip to content

Commit 4ef3482

Browse files
committed
search pre filter.
1 parent 54cc5f9 commit 4ef3482

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/plugins/search/component.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,14 @@ function doSearch(value) {
150150
return;
151151
}
152152

153-
const matchs = search(value);
153+
let matchs = search(value);
154+
155+
if (
156+
options.resultPreHanlder &&
157+
typeof options.resultPreHanlder === 'function'
158+
) {
159+
matchs = options.resultPreHanlder(matchs);
160+
}
154161

155162
let html = '';
156163
matchs.forEach(post => {

src/plugins/search/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const CONFIG = {
1111
hideOtherSidebarContent: false,
1212
namespace: undefined,
1313
pathNamespaces: undefined,
14+
resultPreHanlder: undefined,
1415
};
1516

1617
const install = function (hook, vm) {
@@ -29,6 +30,7 @@ const install = function (hook, vm) {
2930
opts.hideOtherSidebarContent || CONFIG.hideOtherSidebarContent;
3031
CONFIG.namespace = opts.namespace || CONFIG.namespace;
3132
CONFIG.pathNamespaces = opts.pathNamespaces || CONFIG.pathNamespaces;
33+
CONFIG.resultPreHanlder = opts.resultPreHanlder || CONFIG.resultPreHanlder;
3234
}
3335

3436
const isAuto = CONFIG.paths === 'auto';

0 commit comments

Comments
 (0)