-
Notifications
You must be signed in to change notification settings - Fork 84
/
interfaces.ts
130 lines (104 loc) · 2.38 KB
/
interfaces.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import lunr from "lunr";
export interface SmartQuery {
tokens: string[];
keyword: string;
}
export type SmartTerm = string[];
export interface WrappedTerm {
missed: number;
term: SmartTerm;
}
export type MetadataPosition = [number, number];
export interface MatchMetadata {
[token: string]: {
[field: string]: {
position: MetadataPosition[];
};
};
}
export interface HighlightChunk {
html: string;
textLength: number;
}
export interface ChunkIndexRef {
chunkIndex: number;
}
/**
* properties of document is shorten for smaller serialized search index.
*/
export interface SearchDocument {
/** Doc ID. */
i: number;
/** Doc title. */
t: string;
/** Doc URL. */
u: string;
/** Doc parent ID. */
p?: number;
}
export type SearchDocumentType = 0 | 1 | 2;
export interface SearchResultBase {
document: SearchDocument;
type: SearchDocumentType;
page: SearchDocument | undefined | false;
metadata: MatchMetadata;
tokens: string[];
}
export type SearchResult = SearchResultBase & SearchResultExtra;
export type InitialSearchResult = SearchResultBase & Partial<SearchResultExtra>;
export interface SearchResultExtra {
score: number;
index: number;
isInterOfTree: boolean;
isLastOfTree: boolean;
}
export interface WrappedIndex {
documents: SearchDocument[];
index: lunr.Index;
type: SearchDocumentType;
}
export interface ParsedDocument {
pageTitle: string;
sections: ParsedDocumentSection[];
}
export interface ParsedDocumentSection {
title: string;
hash: string;
content: string;
}
export interface DocInfoWithRoute {
route: string;
url: string;
type: DocInfoType;
}
export interface DocInfoWithFilePath {
filePath: string;
url: string;
type: DocInfoType;
}
export type DocInfoType = "docs" | "blog" | "page";
export interface PluginOptions {
indexDocs?: boolean;
indexBlog?: boolean;
indexPages?: boolean;
docsRouteBasePath?: string;
blogRouteBasePath?: string;
language?: string | string[];
hashed?: boolean;
docsDir?: string;
blogDir?: string;
removeDefaultStopWordFilter?: boolean;
searchResultLimits?: number;
searchResultContextMaxLength?: number;
}
export type ProcessedPluginOptions = Required<PluginOptions> & {
language: string[];
};
export interface PostBuildData {
routesPaths: string[];
outDir: string;
baseUrl: string;
}
export interface DocusaurusContext {
siteDir: string;
}