Skip to content

Commit 7c3945b

Browse files
WIP: Documentation website (#52)
1 parent 019af6c commit 7c3945b

64 files changed

Lines changed: 26874 additions & 1339 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
"files": {
99
"ignoreUnknown": false,
10-
"includes": ["src/**/*.ts", "test/**/*.ts"]
10+
"includes": ["src/**/*.ts", "test/**/*.ts", "docs/**/*.tsx", "docs/**/*.ts", "docs/**/*.mdx"]
1111
},
1212
"formatter": {
1313
"enabled": true,

docs/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
/node_modules/
3+
4+
# React Router
5+
/.react-router/
6+
/build/
7+
.source

docs/app/app.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@import 'tailwindcss';
2+
@import 'fumadocs-ui/css/black.css';
3+
@import 'fumadocs-ui/css/preset.css';

docs/app/assets/logo-dark.png

26.4 KB
Loading

docs/app/assets/logo-light.png

19.1 KB
Loading

docs/app/components/search.tsx

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
"use client";
2+
3+
import { create } from "@orama/orama";
4+
import { useDocsSearch } from "fumadocs-core/search/client";
5+
import {
6+
SearchDialog,
7+
SearchDialogClose,
8+
SearchDialogContent,
9+
SearchDialogHeader,
10+
SearchDialogIcon,
11+
SearchDialogInput,
12+
SearchDialogList,
13+
SearchDialogOverlay,
14+
type SharedProps,
15+
} from "fumadocs-ui/components/dialog/search";
16+
import { useI18n } from "fumadocs-ui/contexts/i18n";
17+
18+
function initOrama() {
19+
return create({
20+
schema: { _: "string" },
21+
language: "english",
22+
});
23+
}
24+
25+
export default function DefaultSearchDialog(props: SharedProps) {
26+
const { locale } = useI18n();
27+
const { search, setSearch, query } = useDocsSearch({
28+
type: "static",
29+
initOrama,
30+
locale,
31+
});
32+
33+
return (
34+
<SearchDialog
35+
search={search}
36+
onSearchChange={setSearch}
37+
isLoading={query.isLoading}
38+
{...props}
39+
>
40+
<SearchDialogOverlay />
41+
<SearchDialogContent>
42+
<SearchDialogHeader>
43+
<SearchDialogIcon />
44+
<SearchDialogInput />
45+
<SearchDialogClose />
46+
</SearchDialogHeader>
47+
<SearchDialogList items={query.data !== "empty" ? query.data : null} />
48+
</SearchDialogContent>
49+
</SearchDialog>
50+
);
51+
}

docs/app/docs/page.tsx

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import browserCollections from "fumadocs-mdx:collections/browser";
2+
import type * as PageTree from "fumadocs-core/page-tree";
3+
import * as TabsComponents from "fumadocs-ui/components/tabs";
4+
import { DocsLayout } from "fumadocs-ui/layouts/docs";
5+
import defaultMdxComponents from "fumadocs-ui/mdx";
6+
import {
7+
DocsBody,
8+
DocsDescription,
9+
DocsPage,
10+
DocsTitle,
11+
} from "fumadocs-ui/page";
12+
import { baseOptions } from "@/lib/layout.shared";
13+
import { source } from "@/lib/source";
14+
import type { Route } from "./+types/page";
15+
16+
export async function loader({ params }: Route.LoaderArgs) {
17+
const slugs = params["*"].split("/").filter((v) => v.length > 0);
18+
const page = source.getPage(slugs);
19+
if (!page) throw new Response("Not found", { status: 404 });
20+
21+
return {
22+
path: page.path,
23+
tree: source.getPageTree(),
24+
};
25+
}
26+
27+
const clientLoader = browserCollections.docs.createClientLoader({
28+
component({ toc, default: Mdx, frontmatter }) {
29+
return (
30+
<DocsPage toc={toc}>
31+
<title>{frontmatter.title}</title>
32+
<meta name="description" content={frontmatter.description} />
33+
<DocsTitle>{frontmatter.title}</DocsTitle>
34+
<DocsDescription>{frontmatter.description}</DocsDescription>
35+
<DocsBody>
36+
<Mdx components={{ ...defaultMdxComponents, ...TabsComponents }} />
37+
</DocsBody>
38+
</DocsPage>
39+
);
40+
},
41+
});
42+
43+
export default function Page({ loaderData }: Route.ComponentProps) {
44+
const { tree, path } = loaderData;
45+
const Content = clientLoader.getComponent(path);
46+
47+
return (
48+
<DocsLayout {...baseOptions()} tree={tree as PageTree.Root}>
49+
<Content />
50+
</DocsLayout>
51+
);
52+
}

docs/app/docs/search.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { createFromSource } from "fumadocs-core/search/server";
2+
import { source } from "@/lib/source";
3+
4+
const server = createFromSource(source, {
5+
language: "english",
6+
});
7+
8+
export async function loader() {
9+
return server.staticGET();
10+
}

docs/app/lib/layout.shared.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import type { BaseLayoutProps } from "fumadocs-ui/layouts/shared";
2+
import logoDark from "@/assets/logo-dark.png";
3+
export function baseOptions(): BaseLayoutProps {
4+
return {
5+
nav: {
6+
title: (
7+
<>
8+
<img
9+
src={logoDark}
10+
alt="Ventyd Logo"
11+
style={{ height: "28px", marginBottom: "4px" }}
12+
/>
13+
</>
14+
),
15+
url: "/docs",
16+
},
17+
themeSwitch: {
18+
enabled: false,
19+
},
20+
};
21+
}

docs/app/lib/source.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { docs } from "fumadocs-mdx:collections/server";
2+
import { loader } from "fumadocs-core/source";
3+
4+
export const source = loader({
5+
source: docs.toFumadocsSource(),
6+
baseUrl: "/docs",
7+
});

0 commit comments

Comments
 (0)