barkey/packages/frontend/src/utility/settings-search-index.ts
anatawa12 85a7b10fcd
refactor serach index generator code (#15772)
* refactor: flatten search index

* chore: use Function() to simplify parsing attribute

* chore: remove comment handling

* chore: simplify processing SearchLabel and SearchKeyword element

* chore: use SearchLabel in mutedUsers

* chore: small improvements

* chore: remove a fallback path and simplify the entire code

* fix: result path is not correct

* chore: inline function
2025-04-07 14:35:32 +09:00

35 lines
797 B
TypeScript

/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { searchIndexes as generated } from 'search-index:settings';
import type { GeneratedSearchIndexItem } from 'search-index:settings';
export type SearchIndexItem = {
id: string;
parentId?: string;
path?: string;
label: string;
keywords: string[];
icon?: string;
};
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;
} else {
console.log('[Settings Search Index] Failed to inline', id);
}
}
}
}
export const searchIndexes: SearchIndexItem[] = generated;