1- 'use cache' ;
2-
3- import { VscGithubInverted } from '@react-icons/all-files/vsc/VscGithubInverted' ;
41import type { Metadata } from 'next' ;
5- import Link from 'next/link' ;
62import { Suspense , type PropsWithChildren } from 'react' ;
7- import { EntryPointSelect } from '@/components/EntrypointSelect' ;
8- import { Footer } from '@/components/Footer' ;
9- import { Navigation } from '@/components/Navigation' ;
10- import { Scrollbars } from '@/components/OverlayScrollbars' ;
11- import { PackageSelect } from '@/components/PackageSelect' ;
12- import { SearchButton } from '@/components/SearchButton' ;
13- import { ThemeSwitchNoSRR } from '@/components/ThemeSwitch' ;
14- import { VersionSelect } from '@/components/VersionSelect' ;
15- import { Sidebar , SidebarContent , SidebarHeader , SidebarInset , SidebarTrigger } from '@/components/ui/Sidebar' ;
16- import { buttonStyles } from '@/styles/ui/button' ;
17- import { PACKAGES_WITH_ENTRY_POINTS } from '@/util/constants' ;
18- import { ENV } from '@/util/env' ;
19- import { fetchEntryPoints } from '@/util/fetchEntryPoints' ;
20- import { fetchVersions } from '@/util/fetchVersions' ;
21- import { parseDocsPathParams } from '@/util/parseDocsPathParams' ;
223import { CmdK } from './CmdK' ;
234
245export async function generateMetadata ( {
@@ -44,82 +25,11 @@ export default async function Layout({
4425 params,
4526 children,
4627} : PropsWithChildren < {
47- readonly params : Promise < {
48- readonly item ?: string [ ] | undefined ;
49- readonly packageName : string ;
50- readonly version : string ;
51- } > ;
28+ readonly params : Promise < { readonly packageName : string ; readonly version : string } > ;
5229} > ) {
53- const { packageName, version, item } = await params ;
54-
55- const versions = fetchVersions ( packageName ) ;
56-
57- const hasEntryPoints = PACKAGES_WITH_ENTRY_POINTS . includes ( packageName ) ;
58-
59- const entryPoints = hasEntryPoints ? fetchEntryPoints ( packageName , version ) : Promise . resolve ( [ ] ) ;
60- const { entryPoints : parsedEntrypoints } = parseDocsPathParams ( item ) ;
61-
6230 return (
6331 < >
64- < Sidebar closeButton = { false } intent = "inset" >
65- < SidebarHeader className = "bg-[#f3f3f4] p-4 dark:bg-[#121214]" >
66- < div className = "flex flex-col gap-2" >
67- < div className = "flex place-content-between place-items-center p-1" >
68- < Link className = "text-xl font-bold" href = { `/docs/packages/${ packageName } /${ version } ` } >
69- { packageName }
70- </ Link >
71- < div className = "flex place-items-center gap-2" >
72- < Link
73- aria-label = "GitHub"
74- className = { buttonStyles ( { variant : 'filled' , size : 'icon-sm' } ) }
75- href = "https://github.com/discordjs/discord.js"
76- rel = "external noopener noreferrer"
77- target = "_blank"
78- >
79- < VscGithubInverted aria-hidden data-slot = "icon" size = { 18 } />
80- </ Link >
81- < ThemeSwitchNoSRR />
82- </ div >
83- </ div >
84- < PackageSelect />
85- { /* <h3 className="p-1 text-lg font-semibold">{version}</h3> */ }
86- < VersionSelect versionsPromise = { versions } />
87- { hasEntryPoints ? < EntryPointSelect entryPointsPromise = { entryPoints } /> : null }
88- < SearchButton />
89- </ div >
90- </ SidebarHeader >
91- < SidebarContent className = "bg-[#f3f3f4] p-0 py-4 pl-4 dark:bg-[#121214]" >
92- < Scrollbars >
93- < Navigation entryPoint = { parsedEntrypoints . join ( '.' ) } packageName = { packageName } version = { version } />
94- </ Scrollbars >
95- </ SidebarContent >
96- </ Sidebar >
97- < SidebarInset >
98- { ENV . IS_LOCAL_DEV ? (
99- < div className = "sticky top-0 z-10 flex place-content-center place-items-center border border-red-400/35 bg-red-500/65 p-2 px-4 text-center text-base text-white shadow-md backdrop-blur" >
100- Local test environment
101- </ div >
102- ) : null }
103- { ENV . IS_PREVIEW ? (
104- < div className = "sticky top-0 z-10 flex place-content-center place-items-center border border-red-400/35 bg-red-500/65 p-2 px-4 text-center text-base text-white shadow-md backdrop-blur" >
105- Preview environment
106- </ div >
107- ) : null }
108- < div className = "bg-[#fbfbfb] pb-12 dark:bg-[#1a1a1e]" >
109- < div className = "relative px-6 pt-6 md:hidden" >
110- < div className = "fixed top-5 left-6 z-20 md:hidden" >
111- < SidebarTrigger aria-label = "Navigation" size = "icon" variant = "filled" />
112- </ div >
113- < div className = "flex place-content-end" >
114- < Link className = "text-xl font-bold" href = { `/docs/packages/${ packageName } /${ version } ` } >
115- { packageName }
116- </ Link >
117- </ div >
118- </ div >
119- { children }
120- < Footer />
121- </ div >
122- </ SidebarInset >
32+ { children }
12333 < Suspense >
12434 < CmdK params = { params } />
12535 </ Suspense >
0 commit comments