Skip to content

Commit 8fd510d

Browse files
Merge pull request #329 from nocodb/ai-fuma-upgrade
2 parents 410493c + 73b4ff4 commit 8fd510d

File tree

20 files changed

+620
-487
lines changed

20 files changed

+620
-487
lines changed

app/global.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,11 @@
578578
[id="nd-home-layout"] {
579579
padding-top: 18px !important;
580580
}
581+
[id="nd-toc"] {
582+
right: 0 !important;
583+
inset-inline-end: 0 !important;
584+
}
585+
581586

582587
.grecaptcha-badge {
583588
@apply hidden;

app/llms-full.txt/route.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
import { source, scriptsSource } from '@/lib/source';
1+
import { source, scriptsSource, selfHostingSource } from '@/lib/source';
22
import { getLLMText } from '@/lib/get-llm-txt';
33
// cached forever
44
export const revalidate = false;
55
export async function GET() {
6-
const scan = [...source.getPages(), ...scriptsSource.getPages()].map(getLLMText);
6+
const scan = [
7+
...source.getPages(),
8+
...scriptsSource.getPages(),
9+
...selfHostingSource.getPages()
10+
].map(getLLMText);
711
const scanned = await Promise.all(scan);
812
return new Response(scanned.join('\n\n'));
913
}

app/llms.mdx/[[...slug]]/route.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { getLLMText } from '@/lib/get-llm-txt';
2+
import { source, scriptsSource, selfHostingSource, changelogSource, legalDocsSource } from '@/lib/source';
3+
import { notFound } from 'next/navigation';
4+
5+
export const revalidate = false;
6+
7+
export async function GET(
8+
_req: Request,
9+
props: { params: Promise<{ slug?: string[] }> },
10+
) {
11+
const params = await props.params;
12+
const slug = params.slug || [];
13+
14+
// Determine which source to use based on the path
15+
let page = null;
16+
17+
if (slug[0] === 'product-docs') {
18+
page = source.getPage(slug.slice(1));
19+
} else if (slug[0] === 'scripts') {
20+
page = scriptsSource.getPage(slug.slice(1));
21+
} else if (slug[0] === 'self-hosting') {
22+
page = selfHostingSource.getPage(slug.slice(1));
23+
} else if (slug[0] === 'changelog') {
24+
page = changelogSource.getPage(slug.slice(1));
25+
} else if (slug[0] === 'legal') {
26+
page = legalDocsSource.getPage(slug.slice(1));
27+
}
28+
29+
if (!page) notFound();
30+
31+
try {
32+
return new Response(await getLLMText(page), {
33+
headers: {
34+
'Content-Type': 'text/markdown',
35+
},
36+
});
37+
} catch (error) {
38+
console.error('Failed to generate LLM text:', error);
39+
return new Response('Error generating markdown content', { status: 500 });
40+
}
41+
}
42+
43+
export function generateStaticParams() {
44+
return [
45+
...source.generateParams().map(param => ({ slug: ['product-docs', ...(param.slug || [])] })),
46+
...scriptsSource.generateParams().map(param => ({ slug: ['scripts', ...(param.slug || [])] })),
47+
...selfHostingSource.generateParams().map(param => ({ slug: ['self-hosting', ...(param.slug || [])] })),
48+
...changelogSource.generateParams().map(param => ({ slug: ['changelog', ...(param.slug || [])] })),
49+
...legalDocsSource.generateParams().map(param => ({ slug: ['legal', ...(param.slug || [])] })),
50+
];
51+
}

components/layout/Sidebar.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {cn} from "@/lib/utils";
1111
import {Collapsible, CollapsibleContent, CollapsibleTrigger,} from "@/components/ui/collapsible";
1212
import {ScrollArea, ScrollViewport} from "@/components/ui/scroll-area";
1313
import {useOnChange} from "fumadocs-core/utils/use-on-change";
14+
import { ncIsObject } from "@/utils/is";
1415

1516
interface FolderContextType {
1617
open: boolean;
@@ -109,7 +110,6 @@ function SidebarItem({item, children, level,}: {
109110
}
110111
};
111112

112-
113113
if (item.type === "page") {
114114
return (
115115
<Link
@@ -122,7 +122,7 @@ function SidebarItem({item, children, level,}: {
122122
href={item.url}
123123
onClick={handleLinkClick}
124124
>
125-
{item.icon}
125+
{ncIsObject(item.icon) ? item.icon : ''}
126126
{item.name}
127127
</Link>
128128
);
@@ -131,7 +131,7 @@ function SidebarItem({item, children, level,}: {
131131
if (item.type === "separator") {
132132
return (
133133
<p className="text-fd-muted-foreground mt-6 mb-2 first:mt-0">
134-
{item.icon}
134+
{ncIsObject(item.icon) ? item.icon : ''}
135135
{item.name}
136136
</p>
137137
);
@@ -152,7 +152,7 @@ function SidebarItem({item, children, level,}: {
152152
href={item.index.url}
153153
onClick={handleLinkClick}
154154
>
155-
{item.index.icon}
155+
{ncIsObject(item.index.icon) ? item.index.icon : ''}
156156
{item.index.name}
157157
</Link>
158158
</div>
@@ -165,7 +165,7 @@ function SidebarItem({item, children, level,}: {
165165
active? "text-nc-content-grey-subtle-2 font-[600]" : ""
166166
)}
167167
>
168-
{item.icon}
168+
{ncIsObject(item.icon) ? item.icon : ''}
169169
{item.name}
170170
</div>
171171
</SidebarFolderTrigger>
File renamed without changes.
File renamed without changes.

lib/get-llm-txt.ts

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,13 @@
1-
import { remark } from 'remark';
2-
import remarkGfm from 'remark-gfm';
3-
import remarkMdx from 'remark-mdx';
4-
import { remarkInclude } from 'fumadocs-mdx/config';
5-
import { source } from '@/lib/source';
1+
import { source, blogSource, scriptsSource, selfHostingSource, changelogSource, legalDocsSource } from '@/lib/source';
62
import type { InferPageType } from 'fumadocs-core/source';
73

8-
const processor = remark()
9-
.use(remarkMdx)
10-
.use(remarkInclude)
11-
.use(remarkGfm);
12-
13-
export async function getLLMText(page: InferPageType<typeof source>) {
14-
const processed = await processor.process({
15-
path: page.data._file.absolutePath,
16-
value: page.data.content,
17-
});
4+
export async function getLLMText(page: InferPageType<typeof source | typeof blogSource | typeof scriptsSource | typeof selfHostingSource | typeof changelogSource | typeof legalDocsSource>) {
5+
const processed = await page.data.getText('processed');
186

197
return `# ${page.data.title}
208
URL: ${page.url}
219
22-
${page.data.description}
10+
${page.data.description || ''}
2311
24-
${processed.value}`;
12+
${processed}`;
2513
}

lib/source.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {blog, docs, scripts, selfHosting, changelog, legalDocs} from '@/.source';
22
import {loader} from 'fumadocs-core/source';
3-
import {createMDXSource} from "fumadocs-mdx";
3+
import {createMDXSource} from 'fumadocs-mdx/runtime/next';
44
import {iconMap, IconNameType} from "@/lib/iconMap";
55
import {createElement} from "react";
66

@@ -28,7 +28,7 @@ export const source = loader({
2828

2929
export const blogSource = loader({
3030
baseUrl: '/blog',
31-
source: createMDXSource(blog, []),
31+
source: createMDXSource(blog),
3232
})
3333

3434
export const scriptsSource = loader({

mdx-components.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {ImageZoom} from 'fumadocs-ui/components/image-zoom';
66
export function getMDXComponents(components?: MDXComponents): MDXComponents {
77
return {
88
...defaultMdxComponents,
9-
img: (props) => <ImageZoom {...(props as any)} />,
9+
img: (props) => <ImageZoom {...(props)} />,
1010
...components
1111
};
1212
}

0 commit comments

Comments
 (0)