1- // import { readFile } from 'node:fs/promises';
2- // import { join } from 'node:path';
3- // import { inspect } from 'node:util';
41import type { Metadata } from 'next' ;
52import dynamic from 'next/dynamic' ;
63import type { PropsWithChildren } from 'react' ;
74import { Navigation } from '~/components/Navigation' ;
85import { OverlayScrollbarsComponent } from '~/components/OverlayScrollbars' ;
96import { Drawer } from '~/components/ui/Drawer' ;
107import { Footer } from '~/components/ui/Footer' ;
8+ import { ENV } from '~/util/env' ;
9+ import { fetchDependencies } from '~/util/fetchDependencies' ;
1110
1211// eslint-disable-next-line promise/prefer-await-to-then
1312const CmdK = dynamic ( async ( ) => import ( '~/components/ui/CmdK' ) . then ( ( mod ) => mod . CmdK ) , { ssr : false } ) ;
@@ -29,30 +28,16 @@ export default async function Layout({
2928 params,
3029 children,
3130} : 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 } ) ;
4932
5033 return (
5134 // 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+ >
5439 < 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)]' } ` }
5641 defer
5742 options = { {
5843 overflow : { x : 'hidden' } ,
0 commit comments