import type { SearchRecord } from '@/lib/search'; import { filterRecordsByScope, searchIndex } from '@/lib/search'; import type { SearchProvider } from '@/lib/search/provider'; /** Built-in provider backed by the section index generated during the build. */ export function createLocalSearchProvider(_options: Record = {}): SearchProvider { let records: Promise | null = null; return { async search(query, limit, context) { records ||= import('@/lib/search-index.generated').then(module => module.SEARCH_INDEX); return searchIndex(filterRecordsByScope(await records, context), query, limit); }, }; }