mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-11-10 10:22:18 +00:00
* 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
35 lines
797 B
TypeScript
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;
|
|
|