Skip to content

Commit 175501c

Browse files
committed
add open in llm buttons
1 parent 3cc86b0 commit 175501c

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

app/docs-raw/[[...slug]]/route.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { source } from '@/lib/source';
2+
import { readFile } from 'fs/promises';
3+
import { notFound } from 'next/navigation';
4+
5+
export const dynamic = 'force-static';
6+
7+
export async function GET(
8+
_req: Request,
9+
{ params }: { params: Promise<{ slug?: string[] }> },
10+
) {
11+
const { slug } = await params;
12+
const page = source.getPage(slug);
13+
if (!page || !page.absolutePath) notFound();
14+
15+
const content = await readFile(page.absolutePath, 'utf-8');
16+
return new Response(content, {
17+
headers: { 'Content-Type': 'text/plain; charset=utf-8' },
18+
});
19+
}
20+
21+
export async function generateStaticParams() {
22+
return source.generateParams();
23+
}

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
DocsDescription,
55
DocsPage,
66
DocsTitle,
7+
ViewOptionsPopover,
78
} from 'fumadocs-ui/layouts/docs/page';
89
import { notFound } from 'next/navigation';
910
import { getMDXComponents } from '@/components/mdx';
@@ -23,9 +24,16 @@ export default async function Page(props: {
2324

2425
return (
2526
<DocsPage toc={page.data.toc} full={page.data.full} tableOfContent={{ style: 'clerk' }}>
26-
<div className="flex items-start justify-between gap-4">
27+
<div className="flex flex-wrap items-start justify-between gap-2">
2728
<DocsTitle>{page.data.title}</DocsTitle>
28-
<VersionSelector />
29+
<div className="flex items-center gap-2">
30+
<ViewOptionsPopover
31+
className="p-2 text-sm h-auto"
32+
markdownUrl={`/docs-raw/${(params.slug ?? []).join('/')}`}
33+
githubUrl={`https://github.com/29next/developer-docs/blob/main/content/docs/${page.path}`}
34+
/>
35+
<VersionSelector />
36+
</div>
2937
</div>
3038
<DocsDescription>{page.data.description}</DocsDescription>
3139
<DocsBody>

0 commit comments

Comments
 (0)