Skip to content

Commit a3b6185

Browse files
committed
kms docs
1 parent 62413b3 commit a3b6185

File tree

9 files changed

+214
-73
lines changed

9 files changed

+214
-73
lines changed

apps/docs/app/docs/[[...slug]]/page.tsx

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { DocData, DocMethods } from "fumadocs-mdx/runtime/types";
12
import { DocsBody, DocsPage, DocsTitle } from "fumadocs-ui/page";
23
import type { Metadata } from "next";
34
import { notFound } from "next/navigation";
@@ -7,6 +8,12 @@ import { onRateDocs } from "@/lib/feedback-action";
78
import { getPageImage, source } from "@/lib/source";
89
import { getMDXComponents } from "@/mdx-components";
910

11+
type AsyncPageData = DocMethods & {
12+
title?: string;
13+
description?: string;
14+
load: () => Promise<DocData>;
15+
};
16+
1017
export default async function Page(props: {
1118
params: Promise<{ slug?: string[] }>;
1219
}) {
@@ -16,7 +23,8 @@ export default async function Page(props: {
1623
notFound();
1724
}
1825

19-
const MDX = await page.data.body;
26+
const pageData = page.data as AsyncPageData;
27+
const { body: MDX, toc } = await pageData.load();
2028

2129
return (
2230
<DocsPage
@@ -30,11 +38,10 @@ export default async function Page(props: {
3038
component: <DocsFooter />,
3139
enabled: true,
3240
}}
33-
full={page.data.full}
3441
tableOfContent={{
3542
style: "clerk",
3643
}}
37-
toc={page.data.toc}
44+
toc={toc}
3845
>
3946
<DocsTitle>{page.data.title}</DocsTitle>
4047
<DocsBody>
@@ -58,15 +65,16 @@ export async function generateMetadata(props: {
5865
notFound();
5966
}
6067

68+
const pageTitle = page.data.title ?? "Documentation";
6169
const url = `https://www.databuddy.cc${page.url}`;
62-
const title = `${page.data.title} | Databuddy Documentation`;
70+
const title = `${pageTitle} | Databuddy Documentation`;
6371
const description =
64-
page.data.description ||
65-
`Learn about ${page.data.title} in Databuddy's privacy-first analytics platform. Complete guides and API documentation.`;
72+
page.data.description ??
73+
`Learn about ${pageTitle} in Databuddy's privacy-first analytics platform. Complete guides and API documentation.`;
6674
const ogImage = `https://www.databuddy.cc${getPageImage(page).url}`;
6775

6876
const baseKeywords = [
69-
page.data.title.toLowerCase(),
77+
pageTitle.toLowerCase(),
7078
"databuddy",
7179
"analytics",
7280
"privacy-first",
@@ -125,7 +133,7 @@ export async function generateMetadata(props: {
125133
url: ogImage,
126134
width: 1200,
127135
height: 630,
128-
alt: `${page.data.title} - Databuddy Documentation`,
136+
alt: `${pageTitle} - Databuddy Documentation`,
129137
},
130138
],
131139
},
@@ -156,7 +164,7 @@ export async function generateMetadata(props: {
156164
},
157165
other: {
158166
"article:section": "Documentation",
159-
"article:tag": page.data.title,
167+
"article:tag": pageTitle,
160168
"article:author": "Databuddy Team",
161169
"og:site_name": "Databuddy Documentation",
162170
},

apps/docs/app/global.css

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,33 @@ body {
626626
padding-top: 0px !important;
627627
}
628628

629+
/* Add padding to docs layout to account for fixed navbar and sidebar */
630+
#nd-docs-layout {
631+
padding-top: 64px; /* Account for fixed navbar (h-16 = 64px) */
632+
}
633+
634+
#nd-docs-layout main,
635+
#nd-docs-layout [role="main"],
636+
#nd-docs-layout > div > main {
637+
padding-left: 0;
638+
}
639+
640+
@media (min-width: 768px) {
641+
#nd-docs-layout main,
642+
#nd-docs-layout [role="main"],
643+
#nd-docs-layout > div > main {
644+
padding-left: 268px;
645+
}
646+
}
647+
648+
@media (min-width: 1024px) {
649+
#nd-docs-layout main,
650+
#nd-docs-layout [role="main"],
651+
#nd-docs-layout > div > main {
652+
padding-left: 286px;
653+
}
654+
}
655+
629656
@keyframes borderGlitch {
630657
0% {
631658
border-color: rgb(41 37 36); /* stone-800 */

apps/docs/components/docs-footer.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import { SciFiButton } from "./landing/scifi-btn";
88

99
export function DocsFooter() {
1010
const handleGetStarted = () => {
11-
if (typeof window === "undefined") return;
11+
if (typeof window === "undefined") {
12+
return;
13+
}
1214

1315
const trackingParams = getTrackingParams();
1416
const url = trackingParams
@@ -20,7 +22,7 @@ export function DocsFooter() {
2022

2123
return (
2224
<footer className="border-border border-t bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60">
23-
<div className="mx-auto max-w-6xl px-4 pt-8 sm:px-6 lg:px-8">
25+
<div className="mx-auto max-w-6xl px-4 pt-8 pb-8 sm:px-6 lg:px-8">
2426
{/* CTA Section */}
2527
<div className="mb-10 text-center">
2628
<h2 className="mb-4 font-medium text-xl leading-tight sm:text-2xl">

apps/docs/components/docs-navbar.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import { Logo } from "./logo";
99
import { NavLink } from "./nav-link";
1010
import { contents } from "./sidebar-content";
1111

12-
export type DocsNavbarProps = {
12+
export interface DocsNavbarProps {
1313
stars?: number | null;
14-
};
14+
}
1515

1616
export const DocsNavbar = ({ stars }: DocsNavbarProps) => {
1717
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);
@@ -26,7 +26,7 @@ export const DocsNavbar = ({ stars }: DocsNavbarProps) => {
2626
};
2727

2828
return (
29-
<div className="sticky top-0 z-30 flex flex-col border-border border-b backdrop-blur-md">
29+
<div className="fixed top-0 right-0 left-0 z-30 flex flex-col border-border border-b bg-background/95 backdrop-blur-md">
3030
<nav>
3131
<div className="mx-auto w-full px-2 sm:px-2 md:px-6 lg:px-8">
3232
<div className="flex h-16 items-center justify-between">
@@ -187,10 +187,12 @@ export const DocsNavbar = ({ stars }: DocsNavbarProps) => {
187187
}}
188188
>
189189
<div className="flex items-center gap-2">
190-
<item.icon
191-
className="size-4 shrink-0"
192-
weight="duotone"
193-
/>
190+
{item.icon ? (
191+
<item.icon
192+
className="size-4 shrink-0"
193+
weight="duotone"
194+
/>
195+
) : null}
194196
<span>{item.title}</span>
195197
{item.isNew && (
196198
<span className="rounded border border-border/40 bg-muted/40 px-1.5 py-0.5 text-foreground/80 text-xs">

apps/docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"fast-glob": "^3.3.3",
5252
"fumadocs-core": "15.5.0",
5353
"fumadocs-docgen": "^2.1.0",
54-
"fumadocs-mdx": "13",
54+
"fumadocs-mdx": "14",
5555
"fumadocs-ui": "15.5.0",
5656
"gray-matter": "^4.0.3",
5757
"input-otp": "^1.4.2",

apps/docs/scripts/validate-links.ts

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { InferPageType } from "fumadocs-core/source";
2+
import type { DocData, DocMethods } from "fumadocs-mdx/runtime/types";
23
import {
34
type FileObject,
45
printErrors,
@@ -8,18 +9,29 @@ import {
89
import { source } from "../lib/source";
910

1011
type Page = InferPageType<typeof source>;
12+
type AsyncPageData = DocMethods & {
13+
title?: string;
14+
description?: string;
15+
load: () => Promise<DocData>;
16+
};
1117

12-
const getHeadings = (page: Page): string[] =>
13-
page.data.toc?.map((item) => item.url.slice(1)) ?? [];
18+
const getHeadings = async (page: Page): Promise<string[]> => {
19+
const pageData = page.data as AsyncPageData;
20+
const { toc } = await pageData.load();
21+
return toc?.map((item) => item.url.slice(1)) ?? [];
22+
};
1423

1524
const getFiles = (): Promise<FileObject[]> =>
1625
Promise.all(
17-
source.getPages().map(async (page) => ({
18-
path: page.file.path,
19-
content: await page.data.getText("raw"),
20-
url: page.url,
21-
data: page.data,
22-
}))
26+
source.getPages().map(async (page) => {
27+
const pageData = page.data as AsyncPageData;
28+
return {
29+
path: page.file.path,
30+
content: await pageData.getText("raw"),
31+
url: page.url,
32+
data: page.data,
33+
};
34+
})
2335
);
2436

2537
async function checkLinks() {
@@ -28,10 +40,12 @@ async function checkLinks() {
2840
const scanned = await scanURLs({
2941
preset: "next",
3042
populate: {
31-
"docs/[[...slug]]": pages.map((page) => ({
32-
value: { slug: page.slugs },
33-
hashes: getHeadings(page),
34-
})),
43+
"docs/[[...slug]]": await Promise.all(
44+
pages.map(async (page) => ({
45+
value: { slug: page.slugs },
46+
hashes: await getHeadings(page),
47+
}))
48+
),
3549
},
3650
});
3751

apps/docs/source.config.ts

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,17 @@
11
import {
2-
defineConfig,
32
defineDocs,
43
frontmatterSchema,
54
metaSchema,
65
} from "fumadocs-mdx/config";
7-
import { z } from "zod";
86

9-
// Simplified blog frontmatter schema - separate from docs schema
10-
const blogFrontmatterSchema = z.object({
11-
title: z.string(),
12-
description: z.string().optional(),
13-
icon: z.string().optional(),
14-
full: z.boolean().optional(),
15-
author: z.string(),
16-
publishedAt: z.string(),
17-
lastModified: z.string().optional(),
18-
featured: z.boolean().optional().default(false),
19-
category: z.string(),
20-
tags: z.array(z.string()).optional().default([]),
21-
});
22-
23-
// You can customise Zod schemas for frontmatter and `meta.json` here
24-
// see https://fumadocs.vercel.app/docs/mdx/collections#define-docs
257
export const docs = defineDocs({
268
dir: "content/docs",
279
docs: {
2810
schema: frontmatterSchema,
11+
async: true
2912
},
3013
meta: {
3114
schema: metaSchema,
3215
},
3316
});
3417

35-
export const blogs = defineDocs({
36-
dir: "content/blogs",
37-
docs: {
38-
schema: blogFrontmatterSchema,
39-
},
40-
meta: {
41-
schema: metaSchema,
42-
},
43-
});
44-
45-
export default defineConfig();

apps/docs/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"jsx": "preserve",
1717
"incremental": true,
1818
"paths": {
19-
"fumadocs-mdx:collections/*": ["./source/*"],
19+
"fumadocs-mdx:collections/*": [".source/*"],
2020
"@/*": ["./*"]
2121
},
2222
"plugins": [

0 commit comments

Comments
 (0)