diff --git a/next.config.mjs b/next.config.mjs index 787c58e2..aa49369c 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -5,14 +5,8 @@ const withMDX = createMDX(); /** @type {import('next').NextConfig} */ const config = { reactStrictMode: true, - async rewrites() { - return [ - { - source: "/:path*.md", - destination: "/llms.mdx/:path*", - }, - ]; - }, + output: "export", + images: { unoptimized: true }, }; export default withMDX(config); diff --git a/package.json b/package.json index c4e6a471..1f55f662 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "dependencies": { "@fumadocs/mdx-remote": "^1.4.0", "@netlify/plugin-nextjs": "^5.13.1", + "@orama/orama": "^3.1.13", "@radix-ui/react-collapsible": "^1.1.12", "@radix-ui/react-popover": "^1.1.15", "@radix-ui/react-presence": "^1.1.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0a0199ca..d1b89e39 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,6 +14,9 @@ importers: '@netlify/plugin-nextjs': specifier: ^5.13.1 version: 5.13.1 + '@orama/orama': + specifier: ^3.1.13 + version: 3.1.13 '@radix-ui/react-collapsible': specifier: ^1.1.12 version: 1.1.12(@types/react-dom@19.1.9(@types/react@19.1.12))(@types/react@19.1.12)(react-dom@19.1.1(react@19.1.1))(react@19.1.1) diff --git a/src/app/api/search/route.ts b/src/app/api/search/route.ts index b606c96f..0dc50cde 100644 --- a/src/app/api/search/route.ts +++ b/src/app/api/search/route.ts @@ -1,14 +1,6 @@ -import { structure } from "fumadocs-core/mdx-plugins"; -import { createSearchAPI } from "fumadocs-core/search/server"; +import { createFromSource } from "fumadocs-core/search/server"; import { source } from "@/lib/source"; -export const { GET } = createSearchAPI("advanced", { - language: "english", - indexes: source.getPages().map((page) => ({ - title: page.data.title, - description: page.data.description, - url: page.url, - id: page.url, - structuredData: structure(page.data.content), - })), -}); +// statically cached +export const revalidate = false; +export const { staticGET: GET } = createFromSource(source); diff --git a/src/app/layout.tsx b/src/app/layout.tsx index e211c8f7..ba36ba10 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,7 +1,7 @@ import "@/app/global.css"; -import { RootProvider } from "fumadocs-ui/provider"; import { Inter } from "next/font/google"; import type { ReactNode } from "react"; +import { Provider } from "./provider"; const inter = Inter({ subsets: ["latin"], @@ -11,7 +11,7 @@ export default function Layout({ children }: { children: ReactNode }) { return ( - {children} + {children} ); diff --git a/src/app/llms-full.txt/route.ts b/src/app/llms-full.txt/route.ts deleted file mode 100644 index ed54c019..00000000 --- a/src/app/llms-full.txt/route.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { getLLMText } from "@/lib/get-llm-text"; -import { source } from "@/lib/source"; - -// cached forever -export const revalidate = false; - -export async function GET() { - const scan = source.getPages().map(getLLMText); - const scanned = await Promise.all(scan); - - return new Response(scanned.join("\n\n")); -} diff --git a/src/app/provider.tsx b/src/app/provider.tsx new file mode 100644 index 00000000..5abef462 --- /dev/null +++ b/src/app/provider.tsx @@ -0,0 +1,16 @@ +"use client"; +import { RootProvider } from "fumadocs-ui/provider"; +import type { ReactNode } from "react"; +import SearchDialog from "@/components/search"; + +export function Provider({ children }: { children: ReactNode }) { + return ( + + {children} + + ); +} diff --git a/src/components/search.tsx b/src/components/search.tsx new file mode 100644 index 00000000..aa6845aa --- /dev/null +++ b/src/components/search.tsx @@ -0,0 +1,51 @@ +"use client"; +import { create } from "@orama/orama"; +import { useDocsSearch } from "fumadocs-core/search/client"; +import { + SearchDialog, + SearchDialogClose, + SearchDialogContent, + SearchDialogHeader, + SearchDialogIcon, + SearchDialogInput, + SearchDialogList, + SearchDialogOverlay, + type SharedProps, +} from "fumadocs-ui/components/dialog/search"; +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 ( + + + + + + + + + + + + ); +}