-
Notifications
You must be signed in to change notification settings - Fork 16
/
index.js
32 lines (29 loc) · 948 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const { path } = require("@vuepress/shared-utils");
const { getPageText } = require("./src/utils");
let defaultSearchOptions = {
encode: "icase",
tokenize: "forward",
resolution: 9,
doc: {
id: "key",
field: ["title", "content", "headers"],
},
};
const DEFAULT_SEARCH_RESULT_LENGTH = 60;
module.exports = (options) => ({
extendPageData($page) {
$page.content = getPageText($page, options.noExtraSpaceAfterHtmlTag);
},
alias: {
"@SearchBox": path.resolve(__dirname, "src", "SearchBox.vue"),
},
define: {
SEARCH_OPTIONS: options.search_options || defaultSearchOptions,
SEARCH_MAX_SUGGESTIONS: options.maxSuggestions || 10,
SEARCH_PATHS: options.searchPaths || null,
SEARCH_HOTKEYS: options.searchHotkeys || "s",
SEARCH_RESULT_LENGTH:
Number(options.searchResultLength) || DEFAULT_SEARCH_RESULT_LENGTH,
SEARCH_SPLIT_HIGHLIGHTED_WORDS: options.splitHighlightedWords || null,
},
});