1- import { DocsCopyPage } from '@docs/components/docs-copy-page' ;
2- import { DocsTableOfContents } from '@docs/components/docs-toc' ;
31import { functionsSource } from '@docs/lib/source' ;
4- import { mdxComponents } from '@docs/mdx-components' ;
5- import { Button } from '@docs/ui/button' ;
6- import { IconArrowLeft , IconArrowRight } from '@tabler/icons-react' ;
72import { findNeighbour } from 'fumadocs-core/page-tree' ;
8- import Link from 'next/link' ;
93import { notFound } from 'next/navigation' ;
104
5+ import { FunctionHeader } from '../../_components/function-header' ;
6+
117export const revalidate = false ;
128export const dynamic = 'force-static' ;
139export const dynamicParams = false ;
1410
15- export function generateStaticParams ( ) {
16- return functionsSource . generateParams ( ) ;
11+ export const generateStaticParams = ( ) => functionsSource . generateParams ( ) ;
12+
13+ interface FunctionPageProps {
14+ params : Promise < { name : string ; type : string } > ;
1715}
1816
19- export async function generateMetadata ( props : { params : Promise < { name : string ; type : string } > } ) {
17+ export const generateMetadata = async ( props : FunctionPageProps ) => {
2018 const params = await props . params ;
2119 const page = functionsSource . getPage ( [ params . type , params . name ] ) ;
2220
23- if ( ! page ) {
24- notFound ( ) ;
25- }
26-
27- const doc = page . data ;
28-
29- if ( ! doc . title || ! doc . description ) {
30- notFound ( ) ;
31- }
21+ if ( ! page ) notFound ( ) ;
3222
3323 return {
34- title : doc . title ,
35- description : doc . description
24+ title : page . data . title ,
25+ description : page . data . description
3626 } ;
37- }
27+ } ;
3828
39- export default async function Page ( props : { params : Promise < { name : string ; type : string } > } ) {
29+ const FunctionPage = async ( props : FunctionPageProps ) => {
4030 const params = await props . params ;
4131 const page = functionsSource . getPage ( [ params . type , params . name ] ) ;
4232
43- if ( ! page ) {
44- notFound ( ) ;
45- }
33+ if ( ! page ) notFound ( ) ;
4634
4735 const doc = page . data ;
48- const MDX = doc . body ;
4936 const neighbours = findNeighbour ( functionsSource . pageTree , page . url ) ;
5037 const raw = await doc . getText ( 'raw' ) ;
5138
@@ -57,82 +44,22 @@ export default async function Page(props: { params: Promise<{ name: string; type
5744 < div className = 'flex min-w-0 flex-1 flex-col' >
5845 < div className = 'h-(--top-spacing) shrink-0' />
5946 < div className = 'mx-auto flex w-full max-w-[45rem] min-w-0 flex-1 flex-col gap-6 px-4 py-6 text-neutral-800 md:px-0 lg:py-8 dark:text-neutral-300' >
60- < div className = 'flex flex-col gap-2' >
61- < div className = 'flex flex-col gap-2' >
62- < div className = 'flex items-center justify-between md:items-start' >
63- < h1 className = 'scroll-m-24 text-3xl font-semibold tracking-tight sm:text-3xl' >
64- { doc . title }
65- </ h1 >
66- < div className = 'docs-nav flex items-center gap-2' >
67- < div className = 'hidden sm:block' >
68- < DocsCopyPage page = { raw } />
69- </ div >
70- < div className = 'ml-auto flex gap-2' >
71- { neighbours . previous && (
72- < Button
73- asChild
74- className = 'extend-touch-target size-8 shadow-none md:size-7'
75- size = 'icon'
76- variant = 'secondary'
77- >
78- < Link href = { neighbours . previous . url } >
79- < IconArrowLeft />
80- < span className = 'sr-only' > Previous</ span >
81- </ Link >
82- </ Button >
83- ) }
84- { neighbours . next && (
85- < Button
86- asChild
87- className = 'extend-touch-target size-8 shadow-none md:size-7'
88- size = 'icon'
89- variant = 'secondary'
90- >
91- < Link href = { neighbours . next . url } >
92- < span className = 'sr-only' > Next</ span >
93- < IconArrowRight />
94- </ Link >
95- </ Button >
96- ) }
97- </ div >
98- </ div >
99- </ div >
100- { doc . description && (
101- < p className = 'text-muted-foreground text-[1.05rem] sm:text-base sm:text-balance md:max-w-[90%]' >
102- { doc . description }
103- </ p >
104- ) }
105- </ div >
106- </ div >
107- < div className = 'w-full flex-1 pb-16 *:data-[slot=alert]:first:mt-0 sm:pb-0' >
108- < MDX components = { mdxComponents } />
109- </ div >
110- < div className = 'hidden h-16 w-full items-center gap-2 px-4 sm:flex sm:px-0' >
111- { neighbours . previous && (
112- < Button asChild className = 'shadow-none' size = 'sm' variant = 'secondary' >
113- < Link href = { neighbours . previous . url } >
114- < IconArrowLeft /> { neighbours . previous . name }
115- </ Link >
116- </ Button >
117- ) }
118- { neighbours . next && (
119- < Button asChild className = 'ml-auto shadow-none' size = 'sm' variant = 'secondary' >
120- < Link href = { neighbours . next . url } >
121- { neighbours . next . name } < IconArrowRight />
122- </ Link >
123- </ Button >
124- ) }
125- </ div >
47+ < FunctionHeader
48+ category = { doc . category }
49+ description = { doc . description }
50+ isDemo = { doc . isDemo }
51+ isTest = { doc . isTest }
52+ name = { doc . title }
53+ next = { neighbours . next ?. url }
54+ page = { raw }
55+ previous = { neighbours . previous ?. url }
56+ type = { doc . type }
57+ usage = { doc . usage }
58+ />
12659 </ div >
12760 </ div >
128- < div className = 'sticky top-[calc(var(--header-height)+1px)] z-30 ml-auto hidden h-[90svh] w-(--sidebar-width) flex-col gap-4 overflow-hidden overscroll-none pb-8 xl:flex' >
129- < div className = 'h-(--top-spacing) shrink-0' />
130- { doc . toc ?. length && (
131- < div className = 'no-scrollbar flex flex-col gap-8 overflow-y-auto px-8' >
132- < DocsTableOfContents toc = { doc . toc } />
133- </ div >
134- ) }
135- </ div >
13661 </ div >
13762 ) ;
138- }
63+ } ;
64+
65+ export default FunctionPage ;
0 commit comments