1
1
import type { Metadata } from 'next' ;
2
- import {
3
- DocsBody,
4
- DocsDescription,
5
- DocsPage,
6
- DocsTitle,
7
- } from 'fumadocs-ui/page';
8
- import { notFound } from 'next/navigation';
9
- import {
10
- type ComponentProps,
11
- type FC,
12
- type ReactElement,
13
- type ReactNode,
14
- } from 'react';
2
+ import { type ComponentProps , type FC , type ReactNode } from 'react' ;
15
3
import * as Twoslash from 'fumadocs-twoslash/ui' ;
16
4
import { Callout } from 'fumadocs-ui/components/callout' ;
17
5
import { TypeTable } from 'fumadocs-ui/components/type-table' ;
18
6
import * as Preview from '@/components/preview' ;
19
7
import { createMetadata } from '@/lib/metadata' ;
20
- import { openapi, source } from '@/lib/source';
8
+ import { source } from '@/lib/source' ;
21
9
import { Wrapper } from '@/components/preview/wrapper' ;
22
10
import { Mermaid } from '@/components/mdx/mermaid' ;
23
- import { Rate } from '@/components/rate ';
11
+ import { Feedback } from '@/components/feedback ' ;
24
12
import { onRateAction , owner , repo } from '@/lib/github' ;
25
13
import {
26
14
HoverCard ,
27
15
HoverCardContent ,
28
16
HoverCardTrigger ,
29
17
} from '@/components/ui/hover-card' ;
30
18
import Link from 'fumadocs-core/link' ;
31
- import { UiOverview } from '@/components/ui-overview';
32
19
import { AutoTypeTable } from 'fumadocs-typescript/ui' ;
33
20
import { createGenerator } from 'fumadocs-typescript' ;
34
- import { getPageTreePeers } from 'fumadocs-core/server ';
21
+ import { getPageTreePeers } from 'fumadocs-core/page-tree ' ;
35
22
import { Card , Cards } from 'fumadocs-ui/components/card' ;
36
23
import { getMDXComponents } from '@/mdx-components' ;
37
24
import { APIPage } from 'fumadocs-openapi/ui' ;
38
- import { EditOnGitHub, LLMCopyButton } from './page.client';
25
+ import { LLMCopyButton , ViewOptions } from '@/components/ai/page-actions' ;
26
+ import * as path from 'node:path' ;
27
+ import { Banner } from 'fumadocs-ui/components/banner' ;
28
+ import { openapi } from '@/lib/openapi' ;
29
+ import { Installation } from '@/components/preview/installation' ;
30
+ import { Customisation } from '@/components/preview/customisation' ;
31
+ import { DocsPage } from 'fumadocs-ui/page' ;
32
+ import { NotFound } from '@/components/not-found' ;
33
+ // import { getSuggestions } from '@/app/(docs)/[...slug]/suggestions';
39
34
40
35
function PreviewRenderer ( { preview } : { preview : string } ) : ReactNode {
41
36
if ( preview && preview in Preview ) {
@@ -50,48 +45,46 @@ const generator = createGenerator();
50
45
51
46
export const revalidate = false ;
52
47
53
- export default async function Page(props: {
54
- params: Promise<{ slug: string[] }>;
55
- }): Promise<ReactElement> {
48
+ export default async function Page ( props : PageProps < '/[...slug]' > ) {
56
49
const params = await props . params ;
57
50
const page = source . getPage ( params . slug ) ;
58
51
59
- if (!page) notFound();
52
+ if ( ! page )
53
+ return (
54
+ // <NotFound getSuggestions={() => getSuggestions(params.slug.join(' '))} />
55
+ < NotFound getSuggestions = { ( ) => Promise . resolve ( [ ] ) } />
56
+ ) ;
60
57
61
- const path = `apps/docs/content/docs/${page.file.path}`;
62
58
const preview = page . data . preview ;
63
- const { body: Mdx, toc } = await page.data.load() ;
59
+ const { body : Mdx , toc, lastModified } = page . data ;
64
60
65
61
return (
66
62
< DocsPage
67
63
toc = { toc }
68
- full={page.data.full }
64
+ lastUpdate = { lastModified ? new Date ( lastModified ) : undefined }
69
65
tableOfContent = { {
70
66
style : 'clerk' ,
71
- single: false,
72
- }}
73
- article={{
74
- className: 'max-sm:pb-16',
75
67
} }
76
68
>
77
- <DocsTitle >{page.data.title}</DocsTitle >
78
- <DocsDescription className="mb-0 ">
69
+ < h1 className = "text-[1.75em] font-semibold" > { page . data . title } </ h1 >
70
+ < p className = "text-lg text-fd-muted-foreground " >
79
71
{ page . data . description }
80
- </DocsDescription>
81
- <div className="flex flex-row gap-2 items-center mb-4">
82
- <LLMCopyButton slug={params.slug} />
83
- <EditOnGitHub
84
- url={`https://github.com/${owner}/${repo}/blob/dev/${path}`}
72
+ </ p >
73
+ < div className = "flex flex-row gap-2 items-center border-b pt-2 pb-6" >
74
+ < LLMCopyButton markdownUrl = { `${ page . url } .mdx` } />
75
+ < ViewOptions
76
+ markdownUrl = { `${ page . url } .mdx` }
77
+ githubUrl = { `https://github.com/${ owner } /${ repo } /blob/master/docs/content/docs/${ page . path } ` }
85
78
/>
86
79
</ div >
87
- <DocsBody className="text-fd-foreground/80 ">
80
+ < div className = "prose flex-1 text-fd-foreground/90 " >
88
81
{ preview ? < PreviewRenderer preview = { preview } /> : null }
89
82
< Mdx
90
83
components = { getMDXComponents ( {
91
84
...Twoslash ,
92
85
a : ( { href, ...props } ) => {
93
86
const found = source . getPageByHref ( href ?? '' , {
94
- dir: page.file. dirname,
87
+ dir : path . dirname ( page . path ) ,
95
88
} ) ;
96
89
97
90
if ( ! found ) return < Link href = { href } { ...props } /> ;
@@ -117,6 +110,7 @@ export default async function Page(props: {
117
110
</ HoverCard >
118
111
) ;
119
112
} ,
113
+ Banner,
120
114
Mermaid,
121
115
TypeTable,
122
116
AutoTypeTable : ( props ) => (
@@ -128,15 +122,13 @@ export default async function Page(props: {
128
122
DocsCategory : ( { url } ) => {
129
123
return < DocsCategory url = { url ?? page . url } /> ;
130
124
} ,
131
- UiOverview,
132
-
133
- ...(await import('@/content/docs/ui/components/tabs.client')),
134
- ...(await import('@/content/docs/ui/theme.client')),
125
+ Installation,
126
+ Customisation,
135
127
} ) }
136
128
/>
137
129
{ page . data . index ? < DocsCategory url = { page . url } /> : null }
138
- </DocsBody >
139
- <Rate onRateAction={onRateAction} />
130
+ </ div >
131
+ < Feedback onRateAction = { onRateAction } />
140
132
</ DocsPage >
141
133
) ;
142
134
}
@@ -153,18 +145,21 @@ function DocsCategory({ url }: { url: string }) {
153
145
) ;
154
146
}
155
147
156
- export async function generateMetadata(props: {
157
- params: Promise<{ slug: string[] }>;
158
- } ): Promise<Metadata> {
148
+ export async function generateMetadata (
149
+ props : PageProps < '/[...slug]' > ,
150
+ ) : Promise < Metadata > {
159
151
const { slug = [ ] } = await props . params ;
160
152
const page = source . getPage ( slug ) ;
161
- if (!page) notFound();
153
+ if ( ! page )
154
+ return createMetadata ( {
155
+ title : 'Not Found' ,
156
+ } ) ;
162
157
163
158
const description =
164
- page.data.description ?? 'The library for building documentation sites ';
159
+ page . data . description ?? 'The platform for building ai-driven automations ' ;
165
160
166
161
const image = {
167
- url: ['/og', ...slug, 'image.png '].join('/'),
162
+ url : [ '/og' , ...slug , 'image.webp ' ] . join ( '/' ) ,
168
163
width : 1200 ,
169
164
height : 630 ,
170
165
} ;
@@ -173,7 +168,7 @@ export async function generateMetadata(props: {
173
168
title : page . data . title ,
174
169
description,
175
170
openGraph : {
176
- url: `/docs/ ${page.slugs.join('/')}`,
171
+ url : `/${ page . slugs . join ( '/' ) } ` ,
177
172
images : [ image ] ,
178
173
} ,
179
174
twitter : {
0 commit comments