()
| 51 | }; |
| 52 | |
| 53 | export const useOrama = () => { |
| 54 | const loadPromiseRef = useRef<Promise<void> | null>(null); |
| 55 | |
| 56 | return useMemo(() => { |
| 57 | const db = create({ |
| 58 | schema: { |
| 59 | title: 'string', |
| 60 | description: 'string', |
| 61 | href: 'string', |
| 62 | siteSection: 'string', |
| 63 | }, |
| 64 | }); |
| 65 | |
| 66 | // @ts-expect-error We are overriding a method, an error is expected. |
| 67 | db.search = async options => { |
| 68 | await (loadPromiseRef.current ??= loadOrama(db)); |
| 69 | return search(db, options); |
| 70 | }; |
| 71 | |
| 72 | return db; |
| 73 | }, []) as unknown as OramaCloud; |
| 74 | }; |
| 75 | |
| 76 | const WithSearch: FC = () => { |
| 77 | const t = useTranslations(); |
no test coverage detected