Skip to content

Commit d212240

Browse files
himself65thucpn
andauthored
feat: use fumadoc 15 + tailwind 4 (#1690)
Co-authored-by: thucpn <thucsh2@gmail.com>
1 parent cb73f77 commit d212240

File tree

78 files changed

+2120
-4194
lines changed

Some content is hidden

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

78 files changed

+2120
-4194
lines changed

apps/next/package.json

+20-19
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
"start": "next start",
99
"postdev": "fumadocs-mdx",
1010
"postbuild": "fumadocs-mdx && tsx scripts/post-build.mts",
11-
"build:docs": "cross-env NODE_OPTIONS=\"--max-old-space-size=8192\" typedoc && node ./scripts/generate-docs.mjs"
11+
"build:docs": "cross-env NODE_OPTIONS=\"--max-old-space-size=8192\" typedoc && tsx scripts/generate-docs.mts"
1212
},
1313
"dependencies": {
1414
"@icons-pack/react-simple-icons": "^10.1.0",
15-
"@llamaindex/chat-ui": "0.0.9",
15+
"@llamaindex/chat-ui": "0.2.0",
1616
"@llamaindex/cloud": "workspace:*",
1717
"@llamaindex/core": "workspace:*",
1818
"@llamaindex/node-parser": "workspace:*",
@@ -27,24 +27,24 @@
2727
"@radix-ui/react-slider": "^1.2.1",
2828
"@radix-ui/react-slot": "^1.1.0",
2929
"@radix-ui/react-tooltip": "^1.1.4",
30-
"@vercel/functions": "^1.5.0",
3130
"@scalar/api-client-react": "^1.1.25",
31+
"@vercel/functions": "^1.5.0",
3232
"ai": "^3.4.33",
3333
"class-variance-authority": "^0.7.0",
3434
"clsx": "2.1.1",
3535
"foxact": "^0.2.41",
3636
"framer-motion": "^11.11.17",
37-
"fumadocs-core": "^14.7.7",
38-
"fumadocs-docgen": "^1.3.7",
39-
"fumadocs-mdx": "^11.5.3",
40-
"fumadocs-openapi": "^5.12.0",
41-
"fumadocs-twoslash": "^2.0.3",
42-
"fumadocs-typescript": "^3.0.3",
43-
"fumadocs-ui": "^14.7.7",
37+
"fumadocs-core": "^15.0.15",
38+
"fumadocs-docgen": "^2.0.0",
39+
"fumadocs-mdx": "^11.5.6",
40+
"fumadocs-openapi": "^6.3.0",
41+
"fumadocs-twoslash": "^3.1.0",
42+
"fumadocs-typescript": "^3.1.0",
43+
"fumadocs-ui": "^15.0.15",
4444
"hast-util-to-jsx-runtime": "^2.3.2",
4545
"llamaindex": "workspace:*",
4646
"lucide-react": "^0.460.0",
47-
"next": "15.1.7",
47+
"next": "15.2.0",
4848
"next-themes": "^0.4.3",
4949
"react": "^19.0.0",
5050
"react-dom": "^19.0.0",
@@ -55,8 +55,8 @@
5555
"rehype-katex": "^7.0.1",
5656
"remark-math": "^6.0.0",
5757
"rimraf": "^6.0.1",
58-
"shiki": "^2.3.2",
59-
"shiki-magic-move": "^1.0.0",
58+
"shiki": "^3.1.0",
59+
"shiki-magic-move": "^1.0.1",
6060
"swr": "^2.2.5",
6161
"tailwind-merge": "^2.5.2",
6262
"tailwindcss-animate": "^1.0.7",
@@ -68,26 +68,27 @@
6868
},
6969
"devDependencies": {
7070
"@next/env": "^15.0.3",
71+
"@tailwindcss/postcss": "^4.0.9",
7172
"@types/mdx": "^2.0.13",
7273
"@types/node": "22.9.0",
73-
"@types/react": "^18.3.12",
74-
"@types/react-dom": "^18.3.1",
74+
"@types/react": "^19.0.10",
75+
"@types/react-dom": "^19.0.4",
7576
"autoprefixer": "^10.4.20",
7677
"cross-env": "^7.0.3",
7778
"fast-glob": "^3.3.2",
7879
"gray-matter": "^4.0.3",
7980
"monaco-editor-webpack-plugin": "^7.1.0",
80-
"postcss": "^8.4.49",
81+
"postcss": "^8.5.3",
8182
"raw-loader": "^4.0.2",
8283
"remark": "^15.0.1",
8384
"remark-gfm": "^4.0.0",
8485
"remark-mdx": "^3.1.0",
8586
"remark-stringify": "^11.0.0",
86-
"tailwindcss": "^3.4.15",
87-
"tsx": "^4.19.2",
87+
"tailwindcss": "^4.0.9",
88+
"tsx": "^4.19.3",
8889
"typedoc": "0.27.4",
8990
"typedoc-plugin-markdown": "^4.3.1",
9091
"typedoc-plugin-merge-modules": "^6.1.0",
91-
"typescript": "^5.7.2"
92+
"typescript": "^5.7.3"
9293
}
9394
}

apps/next/postcss.config.js

-6
This file was deleted.

apps/next/postcss.config.mjs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default {
2+
plugins: {
3+
"@tailwindcss/postcss": {},
4+
},
5+
};

apps/next/scripts/generate-docs.mjs renamed to apps/next/scripts/generate-docs.mts

+12-28
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import * as OpenAPI from "fumadocs-openapi";
21
import { generateFiles } from "fumadocs-typescript";
32
import fs from "node:fs";
43
import * as path from "node:path";
5-
import { fileURLToPath } from "node:url";
64
import { rimrafSync } from "rimraf";
75

86
const out = "./src/content/docs/cloud/api";
@@ -15,28 +13,17 @@ rimrafSync(out, {
1513
},
1614
});
1715

18-
void OpenAPI.generateFiles({
19-
input: [
20-
fileURLToPath(
21-
new URL("../../../packages/cloud/openapi.json", import.meta.url),
22-
),
23-
],
24-
output: out,
25-
groupBy: "tag",
26-
});
27-
2816
void generateFiles({
2917
input: ["./src/content/docs/api/**/*.mdx"],
3018
output: (file) => path.resolve(path.dirname(file), path.basename(file)),
3119
transformOutput,
3220
});
3321

34-
function transformOutput(filePath, content) {
22+
function transformOutput(filePath: string, content: string) {
3523
const fileName = path.basename(filePath);
3624
let title = fileName.split(".")[0];
37-
let pageContent = content;
3825
if (title === "index") title = "LlamaIndex API Reference";
39-
return `---\ntitle: ${title}\n---\n\n${transformAbsoluteUrl(pageContent, filePath)}`;
26+
return `---\ntitle: ${title}\n---\n\n${transformAbsoluteUrl(content, filePath)}`;
4027
}
4128

4229
/**
@@ -46,20 +33,17 @@ function transformOutput(filePath, content) {
4633
* [text](BaseVectorStore.mdx#constructors) -> [text](/docs/api/classes/BaseVectorStore#constructors)
4734
* [text](TaskStep.mdx) -> [text](/docs/api/type-aliases/TaskStep)
4835
*/
49-
function transformAbsoluteUrl(content, filePath) {
36+
function transformAbsoluteUrl(content: string, filePath: string) {
5037
const group = path.dirname(filePath).split(path.sep).pop();
51-
return content.replace(
52-
/\]\(([^)]+)\.mdx([^)]*)\)/g,
53-
(match, slug, anchor) => {
54-
const slugParts = slug.split("/");
55-
const fileName = slugParts[slugParts.length - 1];
56-
const fileGroup = slugParts[slugParts.length - 2] ?? group;
57-
const result = ["/docs/api", fileGroup, fileName, anchor]
58-
.filter(Boolean)
59-
.join("/");
60-
return `](${result})`;
61-
},
62-
);
38+
return content.replace(/\]\(([^)]+)\.mdx([^)]*)\)/g, (_, slug, anchor) => {
39+
const slugParts = slug.split("/");
40+
const fileName = slugParts[slugParts.length - 1];
41+
const fileGroup = slugParts[slugParts.length - 2] ?? group;
42+
const result = ["/docs/api", fileGroup, fileName, anchor]
43+
.filter(Boolean)
44+
.join("/");
45+
return `](${result})`;
46+
});
6347
}
6448

6549
// append meta.json for API page

apps/next/scripts/update-llamacloud.mts

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import { upsertBatchPipelineDocumentsApiV1PipelinesPipelineIdDocumentsPut } from "@llamaindex/cloud/api";
22
import fg from "fast-glob";
3-
import {
4-
fileGenerator,
5-
remarkDocGen,
6-
remarkInstall,
7-
typescriptGenerator,
8-
} from "fumadocs-docgen";
3+
import { fileGenerator, remarkDocGen, remarkInstall } from "fumadocs-docgen";
4+
import { remarkAutoTypeTable } from "fumadocs-typescript";
95
import matter from "gray-matter";
106
import * as fs from "node:fs/promises";
117
import path, { relative } from "node:path";
@@ -21,7 +17,8 @@ async function processContent(content: string): Promise<string> {
2117
const file = await remark()
2218
.use(remarkMdx)
2319
.use(remarkGfm)
24-
.use(remarkDocGen, { generators: [typescriptGenerator(), fileGenerator()] })
20+
.use(remarkAutoTypeTable)
21+
.use(remarkDocGen, { generators: [fileGenerator()] })
2522
.use(remarkInstall, { persist: { id: "package-manager" } })
2623
.use(remarkStringify)
2724
.process(content);

apps/next/src/app/global.css

+10-40
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
@tailwind base;
2-
@tailwind components;
3-
@tailwind utilities;
1+
@import "tailwindcss";
2+
@import "fumadocs-ui/css/neutral.css";
3+
@import "fumadocs-ui/css/preset.css";
4+
@plugin "tailwindcss-animate";
5+
@source '../../node_modules/fumadocs-ui/dist/**/*.js';
6+
@source "../../node_modules/fumadocs-openapi/dist/**/*.js",
7+
@source '../../node_modules/@llamaindex/chat-ui/dist/**/*.js';
8+
@config "../../tailwind.config.mjs";
9+
410
@layer base {
511
:root {
612
--page-max-width: 1840px;
@@ -46,6 +52,7 @@
4652
--chart-5: 27 87% 67%;
4753
--radius: 0.5rem;
4854
}
55+
4956
.dark {
5057
--color-neutral-000: #0e0c15;
5158
--color-neutral-100: #252134;
@@ -87,40 +94,3 @@
8794
--chart-5: 340 75% 55%;
8895
}
8996
}
90-
@layer base {
91-
* {
92-
@apply border-border;
93-
}
94-
body {
95-
@apply bg-background text-foreground;
96-
}
97-
98-
/*
99-
* Override default styles for Markdown
100-
*/
101-
.prose
102-
:where(blockquote):not(
103-
:where([class~="not-prose"], [class~="not-prose"] *)
104-
) {
105-
font-style: normal !important;
106-
}
107-
108-
.prose
109-
:where(blockquote p:first-of-type):not(
110-
:where([class~="not-prose"], [class~="not-prose"] *)
111-
):before {
112-
content: none !important;
113-
}
114-
115-
.prose
116-
:where(blockquote p:first-of-type):not(
117-
:where([class~="not-prose"], [class~="not-prose"] *)
118-
):after {
119-
content: none !important;
120-
}
121-
122-
.prose
123-
:where(code):not(:where([class~="not-prose"], [class~="not-prose"] *)) {
124-
@apply text-blue-600 !important;
125-
}
126-
}

apps/next/src/components/code-block.tsx

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as Base from "fumadocs-ui/components/codeblock";
2-
import { toJsxRuntime, type Jsx } from "hast-util-to-jsx-runtime";
2+
import { toJsxRuntime } from "hast-util-to-jsx-runtime";
33
import { Fragment } from "react";
44
import { jsx, jsxs } from "react/jsx-runtime";
55
import { codeToHast } from "shiki";
@@ -39,12 +39,11 @@ export async function CodeBlock({
3939
});
4040

4141
const rendered = toJsxRuntime(hast, {
42-
jsx: jsx as Jsx,
43-
jsxs: jsxs as Jsx,
42+
jsx: jsx,
43+
jsxs: jsxs,
4444
Fragment,
45-
development: false,
45+
development: process.env.NODE_ENV === "development",
4646
components: {
47-
// @ts-expect-error -- JSX component
4847
pre: Base.Pre,
4948
},
5049
});

apps/next/src/components/demo/chat/api/demo.tsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
"use client";
2-
import { ChatInput, ChatMessages, ChatSection } from "@llamaindex/chat-ui";
2+
import {
3+
ChatHandler,
4+
ChatInput,
5+
ChatMessages,
6+
ChatSection,
7+
} from "@llamaindex/chat-ui";
38
import { useChat } from "ai/react";
49

510
export const ChatDemo = () => {
611
const handler = useChat();
712
return (
8-
<ChatSection handler={handler}>
13+
<ChatSection handler={handler as ChatHandler}>
914
<ChatMessages>
1015
<ChatMessages.List className="h-auto max-h-[400px]" />
1116
<ChatMessages.Actions />

apps/next/src/components/demo/chat/rsc/chat-section.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
"use client";
22

33
import {
4+
ChatHandler,
45
ChatInput,
56
ChatMessage,
67
ChatMessages,
78
ChatSection as ChatSectionUI,
9+
Message,
810
} from "@llamaindex/chat-ui";
911
import { useChatRSC } from "./use-chat-rsc";
1012

1113
export const ChatSectionRSC = () => {
1214
const handler = useChatRSC();
1315
return (
14-
<ChatSectionUI handler={handler}>
16+
<ChatSectionUI handler={handler as ChatHandler}>
1517
<ChatMessages>
1618
<ChatMessages.List className="h-auto max-h-[400px]">
1719
{handler.messages.map((message, index) => (
1820
<ChatMessage
1921
key={index}
20-
message={message}
22+
message={message as Message}
2123
isLast={index === handler.messages.length - 1}
2224
>
2325
<ChatMessage.Avatar />

apps/next/src/content/docs/llamaindex/guide/agents/2_create_agent.mdx

+9-14
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ First we'll need to pull in our dependencies. These are:
3434
import { FunctionTool, Settings } from "llamaindex";
3535
import { OpenAI, OpenAIAgent } from "@llamaindex/openai";
3636
import "dotenv/config";
37+
import { z } from "zod";
3738
```
3839

3940
### Initialize your LLM
@@ -86,20 +87,14 @@ This is the most complicated part of creating an agent. We need to define a `Fun
8687
const tool = FunctionTool.from(sumNumbers, {
8788
name: "sumNumbers",
8889
description: "Use this function to sum two numbers",
89-
parameters: {
90-
type: "object",
91-
properties: {
92-
a: {
93-
type: "number",
94-
description: "First number to sum",
95-
},
96-
b: {
97-
type: "number",
98-
description: "Second number to sum",
99-
},
100-
},
101-
required: ["a", "b"],
102-
},
90+
parameters: z.object({
91+
a: z.number({
92+
description: "First number to sum",
93+
}),
94+
b: z.number({
95+
description: "Second number to sum",
96+
}),
97+
}),
10398
});
10499
```
105100

0 commit comments

Comments
 (0)