Skip to content
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
10 changes: 10 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ module.exports = (options) => ({
alias: {
"@SearchBox": path.resolve(__dirname, "src", "SearchBox.vue"),
},
clientDynamicModules: () => {
const hooks = options.hooks || { }
const nullHook = () => {}
return {
name: "select-hooks.js",
content: `export default {
onSelectSearchBox: ${hooks.onSelectSearchBox || nullHook}
}`
};
},
define: {
SEARCH_OPTIONS: options.search_options || defaultSearchOptions,
SEARCH_MAX_SUGGESTIONS: options.maxSuggestions || 10,
Expand Down
2 changes: 2 additions & 0 deletions src/SearchBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import VuepressSearchBox from "@vuepress/plugin-search/SearchBox.vue";
import Flexsearch from "flexsearch";
import { highlightText } from "./utils";
import hooks from '@dynamic/select-hooks';

/* global
SEARCH_MAX_SUGGESTIONS
Expand Down Expand Up @@ -105,6 +106,7 @@ export default {
const path = this.suggestions[i].path

if (this.$route.path !== path) {
hooks.onSelectSearchBox(this.query, this.$route.path, path);
this.$router.push(this.suggestions[i].path)
}

Expand Down