-
Notifications
You must be signed in to change notification settings - Fork 84
/
processPluginOptions.ts
39 lines (38 loc) · 1.05 KB
/
processPluginOptions.ts
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
33
34
35
36
37
38
39
import path from "path";
import { PluginOptions, ProcessedPluginOptions } from "../../shared/interfaces";
export function processPluginOptions(
options: PluginOptions | undefined,
siteDir: string
): ProcessedPluginOptions {
const config = Object.assign(
{
indexDocs: true,
indexBlog: true,
indexPages: false,
docsRouteBasePath: "/docs",
blogRouteBasePath: "/blog",
language: "en",
hashed: false,
docsDir: "docs",
blogDir: "blog",
removeDefaultStopWordFilter: false,
searchResultLimits: 8,
searchResultContextMaxLength: 50,
},
options
) as ProcessedPluginOptions;
config.docsRouteBasePath = (config.docsRouteBasePath as string).replace(
/^\//,
""
);
config.blogRouteBasePath = (config.blogRouteBasePath as string).replace(
/^\//,
""
);
config.docsDir = path.resolve(siteDir, config.docsDir);
config.blogDir = path.resolve(siteDir, config.blogDir);
if (!Array.isArray(config.language)) {
config.language = [config.language];
}
return config;
}