feat(search): add global search across wiki entities

Implement /api/search endpoint for cross-entity querying
Add GlobalSearch component to top navigation bar with categorized results
This commit is contained in:
2026-05-04 14:20:12 +08:00
parent 3dd3998a5c
commit 06e0cbb1c1
8 changed files with 784 additions and 0 deletions

View File

@@ -318,6 +318,35 @@ export interface DailyChecklistItem {
translations?: TranslationMap;
}
export type GlobalSearchGroupType =
| 'pokemon'
| 'habitats'
| 'items'
| 'ancient-artifacts'
| 'recipes'
| 'daily-checklist'
| 'life';
export interface GlobalSearchItem {
id: number;
type: GlobalSearchGroupType;
title: string;
url: string;
summary: string | null;
meta: string | null;
image: EntityImage | PokemonImage | null;
}
export interface GlobalSearchGroup {
type: GlobalSearchGroupType;
items: GlobalSearchItem[];
}
export interface GlobalSearchResults {
query: string;
groups: GlobalSearchGroup[];
}
export type DataToolScope = 'pokemon' | 'habitats' | 'items' | 'artifacts' | 'recipes' | 'checklist';
export interface DataToolScopeSummary {
@@ -1033,6 +1062,8 @@ async function deleteAndGetJson<T>(path: string): Promise<T> {
}
export const api = {
globalSearch: (query: string, signal?: AbortSignal) =>
getJson<GlobalSearchResults>(`/api/search${buildQuery({ query: query.trim() })}`, signal),
languages: () => getJson<Language[]>('/api/languages'),
projectUpdates: (params: ProjectUpdatesParams = {}) =>
getJson<ProjectUpdates>(