MCPcopy Create free account
hub / github.com/nodejs/nodejs.org / useOrama

Function useOrama

apps/site/components/withSearch.tsx:53–74  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

51};
52
53export 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
76const WithSearch: FC = () => {
77 const t = useTranslations();

Callers 1

WithSearchFunction · 0.85

Calls 1

loadOramaFunction · 0.85

Tested by

no test coverage detected