blob: cbc3d87ff8288c3d395ee6082e53c70a0162a10e (
plain)
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
|
/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { GeneratedSearchIndexItem } from 'search-index';
export type SearchIndexItem = {
id: string;
parentId?: string;
path?: string;
label: string;
keywords: string[];
texts: string[];
icon?: string;
};
export function genSearchIndexes(generated: GeneratedSearchIndexItem[]): SearchIndexItem[] {
const rootMods = new Map(generated.map(item => [item.id, item]));
// link inlining here
for (const item of generated) {
if (item.inlining) {
for (const id of item.inlining) {
const inline = rootMods.get(id);
if (inline) {
inline.parentId = item.id;
inline.path = item.path;
} else {
console.log('[Settings Search Index] Failed to inline', id);
}
}
}
}
return generated;
}
|