From 1988a8a34732194434d796aa324f636c63540a60 Mon Sep 17 00:00:00 2001 From: Jakub Novak Date: Fri, 2 Aug 2024 15:20:52 +0200 Subject: [PATCH] Fix broken side panel in docs --- apps/web/src/app/(docs)/docs/layout.tsx | 32 ------------------------- apps/web/src/app/layout.tsx | 27 +++++++++++++++++++-- apps/web/src/middleware.ts | 6 ++++- 3 files changed, 30 insertions(+), 35 deletions(-) delete mode 100644 apps/web/src/app/(docs)/docs/layout.tsx diff --git a/apps/web/src/app/(docs)/docs/layout.tsx b/apps/web/src/app/(docs)/docs/layout.tsx deleted file mode 100644 index 0fd46d5a4..000000000 --- a/apps/web/src/app/(docs)/docs/layout.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import glob from 'fast-glob' - -import { Layout } from '@/components/Layout' - -import { Section } from '@/components/SectionProvider' - -declare global { - // eslint-disable-next-line @typescript-eslint/no-namespace - namespace JSX { - interface IntrinsicElements { - 'chatlio-widget': any; - } - } -} - - -export default async function DocsLayout({ children }) { - const pages = await glob('**/*.mdx', { cwd: 'src/app/(docs)/docs' }) - const allSectionsEntries = (await Promise.all( - pages.map(async filename => [ - '/docs/' + filename.replace(/\(docs\)\/?|(^|\/)page\.mdx$/, ''), - (await import(`./${filename}`)).sections, - ]), - )) as Array<[string, Array
]> - const allSections = Object.fromEntries(allSectionsEntries) - - return ( - - {children} - - ) -} diff --git a/apps/web/src/app/layout.tsx b/apps/web/src/app/layout.tsx index f0c1ce576..11e595ad8 100644 --- a/apps/web/src/app/layout.tsx +++ b/apps/web/src/app/layout.tsx @@ -9,6 +9,9 @@ import { PostHogAnalytics } from '@/utils/usePostHog' import Canonical from '@/components/Navigation/canonical' import { Suspense } from 'react' import { Header } from '@/components/Header' +import glob from 'fast-glob' +import { Section } from '@/components/SectionProvider' +import { Layout } from '@/components/Layout' export const metadata: Metadata = { // TODO: Add metadataBase @@ -28,7 +31,27 @@ export const metadata: Metadata = { }, } +declare global { + // eslint-disable-next-line @typescript-eslint/no-namespace + namespace JSX { + interface IntrinsicElements { + 'chatlio-widget': any; + } + } +} + + export default async function RootLayout({ children }) { + const pages = await glob('**/*.mdx', { cwd: 'src/app/(docs)/docs' }) + const allSectionsEntries = (await Promise.all( + pages.map(async filename => [ + '/docs/' + filename.replace(/\(docs\)\/?|(^|\/)page\.mdx$/, ''), + (await import(`./(docs)/docs/${filename}`)).sections, + ]), + )) as Array<[string, Array
]> + const allSections = Object.fromEntries(allSectionsEntries) + + return ( -
+
{children} -
+ diff --git a/apps/web/src/middleware.ts b/apps/web/src/middleware.ts index 531bb3310..7cb62821c 100644 --- a/apps/web/src/middleware.ts +++ b/apps/web/src/middleware.ts @@ -10,7 +10,11 @@ export async function middleware(req: NextRequest): Promise { url.port = '' if (url.pathname === '' || url.pathname === '/') { - url.hostname = 'e2b-landing-page.framer.website' + if (process.env.NODE_ENV === 'production') { + url.hostname = 'e2b-landing-page.framer.website' + } else { + return NextResponse.redirect(new URL('/dashboard', req.url)) + } } if (url.pathname.startsWith('/terms')) {