1
- // import { readFile } from 'node:fs/promises';
2
- // import { join } from 'node:path';
3
- // import { inspect } from 'node:util';
4
1
import type { Metadata } from 'next' ;
5
2
import dynamic from 'next/dynamic' ;
6
3
import type { PropsWithChildren } from 'react' ;
7
4
import { Navigation } from '~/components/Navigation' ;
8
5
import { OverlayScrollbarsComponent } from '~/components/OverlayScrollbars' ;
9
6
import { Drawer } from '~/components/ui/Drawer' ;
10
7
import { Footer } from '~/components/ui/Footer' ;
8
+ import { ENV } from '~/util/env' ;
9
+ import { fetchDependencies } from '~/util/fetchDependencies' ;
11
10
12
11
// eslint-disable-next-line promise/prefer-await-to-then
13
12
const CmdK = dynamic ( async ( ) => import ( '~/components/ui/CmdK' ) . then ( ( mod ) => mod . CmdK ) , { ssr : false } ) ;
@@ -29,30 +28,16 @@ export default async function Layout({
29
28
params,
30
29
children,
31
30
} : PropsWithChildren < { readonly params : { readonly packageName : string ; readonly version : string } } > ) {
32
- // const fileContent = await readFile(
33
- // join(process.cwd(), `../../packages/${params.packageName}/docs/split/${params.version}.dependencies.api.json`),
34
- // 'utf8',
35
- // );
36
- // const dependencies = JSON.parse(fileContent);
37
-
38
- const isMainVersion = params . version === 'main' ;
39
- const fileContent = await fetch (
40
- `${ process . env . BLOB_STORAGE_URL } /rewrite/${ params . packageName } /${ params . version } .dependencies.api.json` ,
41
- { next : isMainVersion ? { revalidate : 0 } : { revalidate : 604_800 } } ,
42
- ) ;
43
- const parsedDependencies = await fileContent . json ( ) ;
44
- const dependencies = Object . entries < string > ( parsedDependencies )
45
- . filter ( ( [ key ] ) => key . startsWith ( '@discordjs/' ) && ! key . includes ( 'api-extractor' ) )
46
- . map ( ( [ key , value ] ) => `${ key . replace ( '@discordjs/' , '' ) . replaceAll ( '.' , '-' ) } -${ value . replaceAll ( '.' , '-' ) } ` ) ;
47
-
48
- // console.log(inspect(dependencies, { depth: 0 }));
31
+ const dependencies = await fetchDependencies ( { packageName : params . packageName , version : params . version } ) ;
49
32
50
33
return (
51
34
// eslint-disable-next-line react/no-unknown-property
52
- < div vaul-drawer-wrapper = "" className = "mx-auto flex max-w-screen-xl flex-col gap-12 p-6 md:flex-row" >
53
- < div className = "sticky top-6 hidden flex-shrink-0 self-start md:block" >
35
+ < div vaul-drawer-wrapper = "" className = "mx-auto flex max-w-screen-2xl flex-col gap-12 p-6 md:flex-row" >
36
+ < div
37
+ className = { `sticky hidden flex-shrink-0 self-start md:block ${ ENV . IS_LOCAL_DEV || ENV . IS_PREVIEW ? 'top-[64px]' : 'top-6' } ` }
38
+ >
54
39
< OverlayScrollbarsComponent
55
- className = " max-h-[calc(100dvh-48px)]"
40
+ className = { ` ${ ENV . IS_LOCAL_DEV || ENV . IS_PREVIEW ? ' max-h-[calc(100dvh-48px-40px)]' : 'max-h-[calc(100dvh-48px)]' } ` }
56
41
defer
57
42
options = { {
58
43
overflow : { x : 'hidden' } ,
0 commit comments