File size: 3,297 Bytes
13ae717
 
 
 
0b6b0ac
13ae717
 
 
 
 
 
829f9f6
b8dd7a1
13ae717
 
 
0b6b0ac
 
 
13ae717
 
0b6b0ac
13ae717
0b6b0ac
 
 
422f152
13ae717
422f152
13ae717
422f152
13ae717
422f152
 
 
13ae717
 
422f152
13ae717
 
422f152
13ae717
 
 
 
 
422f152
13ae717
422f152
 
13ae717
 
 
422f152
13ae717
 
 
 
 
 
 
 
 
 
 
 
 
0b6b0ac
 
13ae717
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0b6b0ac
 
 
 
13ae717
0b6b0ac
 
829f9f6
 
1fae132
829f9f6
 
0b6b0ac
ec1f23a
0b6b0ac
b8dd7a1
13ae717
 
 
 
0b6b0ac
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/* eslint-disable @typescript-eslint/no-explicit-any */
import type { Metadata, Viewport } from "next";
import { Inter, PT_Sans } from "next/font/google";
import { cookies } from "next/headers";

import TanstackProvider from "@/components/providers/tanstack-query-provider";
import "@/assets/globals.css";
import { Toaster } from "@/components/ui/sonner";
import MY_TOKEN_KEY from "@/lib/get-cookie-name";
import { apiServer } from "@/lib/api";
import AppContext from "@/components/contexts/app-context";
import Script from "next/script";
import IframeDetector from "@/components/iframe-detector";

const inter = Inter({
  variable: "--font-inter-sans",
  subsets: ["latin"],
});

const ptSans = PT_Sans({
  variable: "--font-ptSans-mono",
  subsets: ["latin"],
  weight: ["400", "700"],
});

export const metadata: Metadata = {
  title: "DeepGame | Build Games with AI 🎮",
  description:
    "DeepGame is a game development tool that helps you build 3D games with AI using the Shalloteer engine. Vibe code your games with natural language and deploy instantly.",
  openGraph: {
    title: "DeepGame | Build Games with AI 🎮",
    description:
      "DeepGame is a game development tool that helps you build 3D games with AI using the Shalloteer engine. Vibe code your games with natural language and deploy instantly.",
    url: "https://deepgame.hf.co",
    siteName: "DeepGame",
    images: [
      {
        url: "https://deepgame.hf.co/banner.png",
        width: 1200,
        height: 630,
        alt: "DeepGame Open Graph Image",
      },
    ],
  },
  twitter: {
    card: "summary_large_image",
    title: "DeepGame | Build Games with AI 🎮",
    description:
      "DeepGame is a game development tool that helps you build 3D games with AI using the Shalloteer engine. Vibe code your games with natural language and deploy instantly.",
    images: ["https://deepgame.hf.co/banner.png"],
  },
  appleWebApp: {
    capable: true,
    title: "DeepGame",
    statusBarStyle: "black-translucent",
  },
  icons: {
    icon: "/logo.svg",
    shortcut: "/logo.svg",
    apple: "/logo.svg",
  },
};

export const viewport: Viewport = {
  initialScale: 1,
  maximumScale: 1,
  themeColor: "#000000",
};

async function getMe() {
  const cookieStore = await cookies();
  const token = cookieStore.get(MY_TOKEN_KEY())?.value;
  if (!token) return { user: null, errCode: null };
  try {
    const res = await apiServer.get("/me", {
      headers: {
        Authorization: `Bearer ${token}`,
      },
    });
    return { user: res.data.user, errCode: null };
  } catch (err: any) {
    return { user: null, errCode: err.status };
  }
}

export default async function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  const data = await getMe();
  return (
    <html lang="en">
      <Script
        defer
        data-domain="deepgame.hf.co"
        src="https://plausible.io/js/script.js"
      ></Script>
      <body
        className={`${inter.variable} ${ptSans.variable} antialiased bg-black dark h-[100dvh] overflow-hidden`}
      >
        <IframeDetector />
        <Toaster richColors position="bottom-center" />
        <TanstackProvider>
          <AppContext me={data}>{children}</AppContext>
        </TanstackProvider>
      </body>
    </html>
  );
}