11"use client" ;
22
3- import React , { useState } from "react" ;
3+ import React , { Suspense , useState } from "react" ;
44import { ViewerLayout } from "@/components/layout/viewer-layout" ;
55import { Sidebar } from "@/components/sidebar/sidebar" ;
66
7- import { usePathname , useSearchParams } from "next/navigation" ;
8- import featureConfig from "@/config" ;
7+ import { useSearchParams } from "next/navigation" ;
98
109export 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-
2210 return (
2311 < ViewerLayout showFileTree = { false } showCodeEditor = { false } >
2412 < div className = "flex h-full w-full overflow-hidden" >
2513 { /* Sidebar */ }
26- { ! sidebarDisabled && < Sidebar activeTab = { "preview" } readmeContent = { "" } pickerDisabled = { integrationPickerDisabled } /> }
14+ < Suspense >
15+ < MaybeSidebar />
16+ </ Suspense >
17+
2718
2819 { /* Content */ }
2920 < div className = "flex-1 overflow-auto" >
@@ -33,3 +24,12 @@ export function MainLayout({ children }: { children: React.ReactNode }) {
3324 </ ViewerLayout >
3425 ) ;
3526}
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