Skip to content

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

Enhance documentation structure and API metadata

Bill Yang72488f1f0deb
diff --git a/docs/content/docs/(docs)/meta.json b/docs/content/docs/(docs)/meta.json
index 8a1bc1956..bc45c8a40 100644
--- a/docs/content/docs/(docs)/meta.json
+++ b/docs/content/docs/(docs)/meta.json
@@ -1,5 +1,8 @@
{
"title": "Documentation",
+ "description": "Guides, setup, and feature documentation",
+ "icon": "Book",
+ "root": true,
"pages": [
"index",
"comparison",
@@ -15,7 +18,6 @@
"guides",
"proxy-guide",
"sdks",
- "api",
"hiding-own-traffic",
"filter-traffic",
"bot-detection",
diff --git a/docs/content/docs/api/meta.json b/docs/content/docs/api/meta.json
index 563a5d4e1..b9229df2a 100644
--- a/docs/content/docs/api/meta.json
+++ b/docs/content/docs/api/meta.json
@@ -1,4 +1,7 @@
{
- "title": "API",
+ "title": "API Reference",
+ "description": "REST API endpoints and authentication",
+ "icon": "Terminal",
+ "root": true,
"pages": ["getting-started", "sending-events", "stats", "organizations", "sites"]
}
diff --git a/docs/content/docs/meta.json b/docs/content/docs/meta.json
new file mode 100644
index 000000000..9b53f9677
--- /dev/null
+++ b/docs/content/docs/meta.json
@@ -0,0 +1,3 @@
+{
+ "pages": ["(docs)", "api"]
+}
diff --git a/docs/src/app/[locale]/docs/[[...slug]]/page.tsx b/docs/src/app/[locale]/docs/[[...slug]]/page.tsx
index 025023b1a..3e6b92b9f 100644
--- a/docs/src/app/[locale]/docs/[[...slug]]/page.tsx
+++ b/docs/src/app/[locale]/docs/[[...slug]]/page.tsx
@@ -19,9 +19,8 @@ export default async function Page(props: {
if (!page) notFound();
const MDXContent = page.data.body;
- // Remove /docs prefix from page.url to get the file path
- const filePath = page.url.replace(/^\/docs/, '');
-
+ // page.path is the source file path relative to the content dir
+ // (e.g. "(docs)/script.mdx"), which maps to the real GitHub location.
return (
<DocsPage toc={page.data.toc} full={page.data.full}>
<DocsTitle>{page.data.title}</DocsTitle>
@@ -30,7 +29,7 @@ export default async function Page(props: {
<LLMCopyButton markdownUrl={`${page.url}.mdx`} />
<ViewOptions
markdownUrl={`${page.url}.mdx`}
- githubUrl={`https://github.com/rybbit-io/rybbit/blob/master/docs/content/docs${filePath}.mdx`}
+ githubUrl={`https://github.com/rybbit-io/rybbit/blob/master/docs/content/docs/${page.path}`}
/>
</div>
<DocsBody>
diff --git a/docs/src/app/api/search/route.ts b/docs/src/app/api/search/route.ts
index 4b34615c0..0a792e0f2 100644
--- a/docs/src/app/api/search/route.ts
+++ b/docs/src/app/api/search/route.ts
@@ -6,16 +6,16 @@ import { createFromSource } from 'fumadocs-core/search/server';
// once and runs Orama in the browser, so there are no per-keystroke round-trips.
export const revalidate = false;
-export const { staticGET: GET } = createFromSource(source, {
- // The source declares 10 i18n languages, so search builds one index per
- // locale. Orama has no stemmer for these languages, which throws
- // `Language "<x>" is not supported` and breaks the static index export.
- // The docs are English-only, so fall back to the English tokenizer for them.
- // https://docs.orama.com/open-source/supported-languages
- localeMap: {
- zh: 'english',
- pl: 'english',
- ko: 'english',
- ja: 'english',
- },
-});
+// The docs source declares 10 i18n languages but the docs themselves are
+// 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.
+const englishOnlySource = {
+ ...source,
+ _i18n: { ...source._i18n, languages: ['en'], defaultLanguage: 'en' },
+ getPages: () => source.getPages('en'),
+};
+
+export const { staticGET: GET } = createFromSource(englishOnlySource);
diff --git a/docs/src/lib/source.ts b/docs/src/lib/source.ts
index 8860a09d6..cf082ffa9 100644
--- a/docs/src/lib/source.ts
+++ b/docs/src/lib/source.ts
@@ -1,6 +1,8 @@
import { docs, meta } from '@/.source';
import { InferPageType, loader } from 'fumadocs-core/source';
import { toFumadocsSource } from 'fumadocs-mdx/runtime/server';
+import { icons } from 'lucide-react';
+import { createElement } from 'react';
import { i18n } from './i18n';
// See https://fumadocs.vercel.app/docs/headless/source-api for more info
@@ -8,6 +10,12 @@ export const source = loader({
i18n,
// it assigns a URL to your pages
baseUrl: '/docs',
+ // resolve string `icon` names from meta.json to lucide-react icons
+ icon(icon) {
+ if (icon && icon in icons) {
+ return createElement(icons[icon as keyof typeof icons]);
+ }
+ },
source: toFumadocsSource(docs, meta),
});