Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Refactor search route to optimize i18n handling

Bill Yang0ff4fe7b2ccb
diff --git a/docs/src/app/api/search/route.ts b/docs/src/app/api/search/route.ts
index 0a792e0f2..b91112a28 100644
--- a/docs/src/app/api/search/route.ts
+++ b/docs/src/app/api/search/route.ts
@@ -1,5 +1,5 @@
-import { source } from '@/lib/source';
-import { createFromSource } from 'fumadocs-core/search/server';
+import { source } from "@/lib/source";
+import { createFromSource } from "fumadocs-core/search/server";
// Build the search index at build time and serve it as a static, CDN-cacheable
// file. The client (RootProvider `search.options.type = 'static'`) downloads it
@@ -7,15 +7,15 @@ import { createFromSource } from 'fumadocs-core/search/server';
export const revalidate = false;
// The docs source declares 10 i18n languages but the docs themselves are
-// English-only — Fumadocs' i18n fallback would otherwise index the full English
+// English-only . Fumadocs' i18n fallback would otherwise index the full English
// content once per locale, producing a ~61MB index (10x duplication) that the
-// static client has to download. We restrict search to a single English index:
-// the `en` locale matches directly, and the static client falls back to it for
-// every other locale, so search returns the (English) docs on every page.
+// static client has to download. Export this as a single non-i18n index: the
+// static Orama client treats i18n keys as Orama language names, and `en` is not
+// a supported Orama language key during hydration.
const englishOnlySource = {
...source,
- _i18n: { ...source._i18n, languages: ['en'], defaultLanguage: 'en' },
- getPages: () => source.getPages('en'),
+ _i18n: undefined,
+ getPages: () => source.getPages("en"),
};
export const { staticGET: GET } = createFromSource(englishOnlySource);