Orama Cloud
Fumadocs UI で Orama Cloud を使用する方法。
セットアップ
Fumadocs CLI を使うと、セットアップを自動で行えます。検索ダイアログ、static.json ルート、およびビルドのたびに検索インデックスを同期するスクリプトが作成されます。
npx @fumadocs/cli feature search --provider orama-cloud手動で設定する場合は、次の手順に従います。
-
Orama Cloud を統合します。
-
検索ダイアログを作成し、
endpointとapi_keyを使用する値に置き換えます。components/search.tsx 'use client'; import { SearchDialog, SearchDialogClose, SearchDialogContent, SearchDialogFooter, SearchDialogHeader, SearchDialogIcon, SearchDialogInput, SearchDialogList, SearchDialogOverlay, type SharedProps, } from 'fumadocs-ui/components/dialog/search'; import { useOramaCloudSearch } from 'fumadocs-core/search/client'; import { OramaCloud } from '@orama/core'; import { useI18n } from 'fumadocs-ui/contexts/i18n'; const orama = new OramaCloud({ projectId: '', apiKey: '', }); export default function CustomSearchDialog(props: SharedProps) { const { locale } = useI18n(); // (optional) for i18n const search = useOramaCloudSearch({ client: orama, locale, }); return ( <SearchDialog {...search} {...props}> <SearchDialogOverlay /> <SearchDialogContent> <SearchDialogHeader> <SearchDialogIcon /> <SearchDialogInput /> <SearchDialogClose /> </SearchDialogHeader> <SearchDialogList /> <SearchDialogFooter> <a href="https://orama.com" rel="noreferrer noopener" className="ms-auto text-xs text-fd-muted-foreground" > Search powered by Orama </a> </SearchDialogFooter> </SearchDialogContent> </SearchDialog> ); }
検索ダイアログを置き換える
プロバイダーコンポーネントはすでに src/components/search.tsx を <RootProvider /> に渡しているため、このファイルを置き換えるだけで済みます。
import { navigate } from 'astro:transitions/client';
import type { ReactNode } from 'react';
import { RootProvider } from 'fumadocs-ui/provider/astro';
import SearchDialog from '@/components/search';
export interface ProviderProps {
pathname: string;
params: Record<string, string | undefined>;
children?: ReactNode;
}
export function Provider({ pathname, params, children }: ProviderProps) {
return (
<RootProvider
pathname={pathname}
params={params}
navigate={navigate}
search={{ SearchDialog }}
>
{children}
</RootProvider>
);
}How is this guide?
最終更新日
