From 0620b988e089b4815d9486e57fe619d2d5d206eb Mon Sep 17 00:00:00 2001 From: Wesley Luyten Date: Sun, 25 Feb 2024 11:56:15 -0600 Subject: [PATCH] example: fix RSC dup render bug, next-themes --- examples/default-provider/app/layout.tsx | 67 ++++++++++--------- examples/default-provider/app/nav.tsx | 7 -- examples/default-provider/app/page.tsx | 4 +- examples/default-provider/app/providers.tsx | 11 --- .../app/slotted-poster/page.tsx | 2 +- examples/default-provider/app/theme-toggle.js | 39 +++++++++++ examples/default-provider/next.config.mjs | 4 +- examples/default-provider/package-lock.json | 11 --- examples/default-provider/package.json | 1 - 9 files changed, 80 insertions(+), 66 deletions(-) delete mode 100644 examples/default-provider/app/providers.tsx create mode 100644 examples/default-provider/app/theme-toggle.js diff --git a/examples/default-provider/app/layout.tsx b/examples/default-provider/app/layout.tsx index aee5bb1..98d1c14 100644 --- a/examples/default-provider/app/layout.tsx +++ b/examples/default-provider/app/layout.tsx @@ -1,19 +1,26 @@ -import type { Metadata } from "next"; -import Link from "next/link"; +import { dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import * as fs from 'node:fs/promises'; + +import type { Metadata } from 'next'; +import Link from 'next/link'; import { DM_Sans, JetBrains_Mono } from 'next/font/google'; -import { Providers } from './providers'; -import Nav from "./nav"; -import "./globals.css"; +import Nav from './nav'; +import './globals.css'; const dmSans = DM_Sans({ subsets: ['latin'], variable: '--sans' }); const jetBrainsMono = JetBrains_Mono({ subsets: ['latin'], variable: '--mono' }); export const metadata: Metadata = { - title: "next-video", - description: "Next Video solves the hard problems with embedding, storing, streaming, and customizing video in your Next.js app.", + title: 'next-video', + description: + 'Next Video solves the hard problems with embedding, storing, streaming, and customizing video in your Next.js app.', }; -export default function RootLayout({ +const fileDir = dirname(fileURLToPath(import.meta.url)); +const themeScript = await fs.readFile(`${fileDir}/theme-toggle.js`, 'utf-8'); + +export default async function RootLayout({ children, }: Readonly<{ children: React.ReactNode; @@ -25,29 +32,27 @@ export default function RootLayout({ className={`${dmSans.variable} ${jetBrainsMono.variable}`} > - -
- - next-video - playground - -
- - - {children} -
+