Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update layout.tsx #115

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 43 additions & 2 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Analytics } from "@vercel/analytics/react";
import { Metadata } from "next";
import "../styles/globals.css";
import Script from 'next/script';
import { useState } from 'react';

// Metadata configuration
let title = "Dream Room Generator";
let description = "Generate your dream room in seconds.";
let ogimage = "https://roomgpt-demo.vercel.app/og-image.png";
Expand All @@ -12,6 +15,9 @@ export const metadata: Metadata = {
description,
icons: {
icon: "/favicon.ico",
apple: "/apple-touch-icon.png",
android: "/android-chrome-192x192.png",
other: "/site.webmanifest",
},
openGraph: {
images: [ogimage],
Expand All @@ -35,11 +41,46 @@ export default function RootLayout({
}: {
children: React.ReactNode;
}) {
const [theme, setTheme] = useState('dark');

const toggleTheme = () => {
setTheme(theme === 'dark' ? 'light' : 'dark');
};

return (
<html lang="en">
<body className="bg-[#17181C] text-white">
<html lang="en" className={theme}>
<body className={theme === 'dark' ? "bg-[#17181C] text-white" : "bg-white text-black"}>
<button
onClick={toggleTheme}
aria-label="Toggle theme"
style={{ position: 'fixed', top: '1rem', right: '1rem' }}
>
Toggle Theme
</button>
{children}
<Analytics />
{/* Google Tag Manager */}
<Script
id="gtm"
strategy="afterInteractive"
dangerouslySetInnerHTML={{
__html: `
(function(w,d,s,l,i){
w[l]=w[l]||[];
w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});
var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';
j.async=true;
j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;
f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXX');
`,
}}
/>
{/* SEO Enhancements */}
<meta name="robots" content="index, follow" />
<link rel="canonical" href="https://roomgpt-demo.vercel.app" />
</body>
</html>
);
Expand Down