Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

search pre filter. #1816

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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