1
1
"use client" ;
2
2
3
- import React , { useState } from "react" ;
3
+ import React , { Suspense , useState } from "react" ;
4
4
import { ViewerLayout } from "@/components/layout/viewer-layout" ;
5
5
import { Sidebar } from "@/components/sidebar/sidebar" ;
6
6
7
- import { usePathname , useSearchParams } from "next/navigation" ;
8
- import featureConfig from "@/config" ;
7
+ import { useSearchParams } from "next/navigation" ;
9
8
10
9
export function MainLayout ( { children } : { children : React . ReactNode } ) {
11
- const pathname = usePathname ( ) ;
12
- const searchParams = useSearchParams ( ) ;
13
-
14
- const sidebarDisabled = searchParams . get ( "sidebar" ) === "disabled" ;
15
- const integrationPickerDisabled = searchParams . get ( "picker" ) === "false" ;
16
-
17
- // Extract the current demo ID from the pathname
18
- const pathParts = pathname . split ( "/" ) ;
19
- const currentFeatureId = pathParts [ pathParts . length - 1 ] ;
20
- const currentFeature = featureConfig . find ( ( d ) => d . id === currentFeatureId ) ;
21
-
22
10
return (
23
11
< ViewerLayout showFileTree = { false } showCodeEditor = { false } >
24
12
< div className = "flex h-full w-full overflow-hidden" >
25
13
{ /* Sidebar */ }
26
- { ! sidebarDisabled && < Sidebar activeTab = { "preview" } readmeContent = { "" } pickerDisabled = { integrationPickerDisabled } /> }
14
+ < Suspense >
15
+ < MaybeSidebar />
16
+ </ Suspense >
17
+
27
18
28
19
{ /* Content */ }
29
20
< div className = "flex-1 overflow-auto" >
@@ -33,3 +24,12 @@ export function MainLayout({ children }: { children: React.ReactNode }) {
33
24
</ ViewerLayout >
34
25
) ;
35
26
}
27
+
28
+ function MaybeSidebar ( ) {
29
+ const searchParams = useSearchParams ( ) ;
30
+
31
+ const sidebarDisabled = searchParams . get ( "sidebar" ) === "disabled" ;
32
+ const integrationPickerDisabled = searchParams . get ( "picker" ) === "false" ;
33
+
34
+ return ! sidebarDisabled && < Sidebar activeTab = { "preview" } readmeContent = { "" } pickerDisabled = { integrationPickerDisabled } /> ;
35
+ }
0 commit comments