Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import "@/app/global.css"
import { RootProvider } from "fumadocs-ui/provider"
// import { RootProvider } from "fumadocs-ui/provider"
import { Provider } from "./provider"

import { Inter } from "next/font/google"

const inter = Inter({
Expand All @@ -10,7 +12,7 @@ export default function Layout({ children }: LayoutProps<"/">) {
return (
<html lang="en" className={inter.className} suppressHydrationWarning>
<body className="flex flex-col min-h-screen">
<RootProvider>{children}</RootProvider>
<Provider>{children}</Provider>
</body>
</html>
)
Expand Down
17 changes: 17 additions & 0 deletions docs/app/provider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"use client"
import { RootProvider } from "fumadocs-ui/provider"
// your custom dialog
import SearchDialog from "@/components/search"
import type { ReactNode } from "react"

export function Provider({ children }: { children: ReactNode }) {
return (
<RootProvider
search={{
SearchDialog
}}
>
{children}
</RootProvider>
)
}
46 changes: 46 additions & 0 deletions docs/components/search.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"use client"
import {
SearchDialog,
SearchDialogClose,
SearchDialogContent,
SearchDialogHeader,
SearchDialogIcon,
SearchDialogInput,
SearchDialogList,
SearchDialogOverlay,
type SharedProps
} from "fumadocs-ui/components/dialog/search"
import { useDocsSearch } from "fumadocs-core/search/client"
import { create } from "@orama/orama"
import { useI18n } from "fumadocs-ui/contexts/i18n"

function initOrama() {
return create({
schema: { _: "string" },
// https://docs.orama.com/docs/orama-js/supported-languages
language: "english"
})
}

export default function DefaultSearchDialog(props: SharedProps) {
const { locale } = useI18n() // (optional) for i18n
const { search, setSearch, query } = useDocsSearch({
type: "static",
initOrama,
locale
})

return (
<SearchDialog search={search} onSearchChange={setSearch} isLoading={query.isLoading} {...props}>
<SearchDialogOverlay />
<SearchDialogContent>
<SearchDialogHeader>
<SearchDialogIcon />
<SearchDialogInput />
<SearchDialogClose />
</SearchDialogHeader>
<SearchDialogList items={query.data !== "empty" ? query.data : null} />
</SearchDialogContent>
</SearchDialog>
)
}
1 change: 1 addition & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"postinstall": "fumadocs-mdx"
},
"dependencies": {
"@orama/orama": "^3.1.11",
"fumadocs-core": "15.7.2",
"fumadocs-mdx": "11.8.0",
"fumadocs-ui": "15.7.2",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.