Skip to content

Commit

Permalink
search pre filter.
Browse files Browse the repository at this point in the history
  • Loading branch information
Koooooo-7 committed Jun 5, 2022
1 parent 54cc5f9 commit 4ef3482
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/plugins/search/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,14 @@ function doSearch(value) {
return;
}

const matchs = search(value);
let matchs = search(value);

if (
options.resultPreHanlder &&
typeof options.resultPreHanlder === 'function'
) {
matchs = options.resultPreHanlder(matchs);
}

let html = '';
matchs.forEach(post => {
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/search/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const CONFIG = {
hideOtherSidebarContent: false,
namespace: undefined,
pathNamespaces: undefined,
resultPreHanlder: undefined,
};

const install = function (hook, vm) {
Expand All @@ -29,6 +30,7 @@ const install = function (hook, vm) {
opts.hideOtherSidebarContent || CONFIG.hideOtherSidebarContent;
CONFIG.namespace = opts.namespace || CONFIG.namespace;
CONFIG.pathNamespaces = opts.pathNamespaces || CONFIG.pathNamespaces;
CONFIG.resultPreHanlder = opts.resultPreHanlder || CONFIG.resultPreHanlder;
}

const isAuto = CONFIG.paths === 'auto';
Expand Down

0 comments on commit 4ef3482

Please sign in to comment.