81 lines
2.3 KiB
TypeScript
81 lines
2.3 KiB
TypeScript
// RootLayout.tsx
|
|
"use client";
|
|
import { fontSans } from "@/config/fonts";
|
|
import { siteConfig } from "@/config/site";
|
|
import { Inter } from "next/font/google";
|
|
|
|
import "@/styles/globals.css";
|
|
import clsx from "clsx";
|
|
import { Metadata } from "next";
|
|
import { Providers } from "./providers";
|
|
import LoadScript from "@/utils/global";
|
|
import { NextIntlClientProvider } from "next-intl";
|
|
import { useEffect, useState, type ReactNode } from "react";
|
|
import storedLanguage from "@/store/language-store";
|
|
const inter = Inter({ subsets: ["latin"] });
|
|
|
|
// export const metadata: Metadata = {
|
|
// title: {
|
|
// default: siteConfig.name,
|
|
// template: `%s - ${siteConfig.name}`,
|
|
// },
|
|
// description: siteConfig.description,
|
|
// themeColor: [
|
|
// { media: "(prefers-color-scheme: light)", color: "white" },
|
|
// { media: "(prefers-color-scheme: dark)", color: "black" },
|
|
// ],
|
|
// icons: {
|
|
// icon: "/logohumas.ico",
|
|
// shortcut: "/favicon-16x16.png",
|
|
// apple: "/apple-touch-icon.png",
|
|
// },
|
|
// };
|
|
|
|
export default function RootLayout({ children }: { children: ReactNode }) {
|
|
const [localeNow, setLocaleNow] = useState<string>("id");
|
|
|
|
const locale = storedLanguage((state) => state.locale);
|
|
|
|
useEffect(() => {
|
|
if (locale) {
|
|
setLocaleNow(locale);
|
|
}
|
|
}, [locale]);
|
|
|
|
const [messages, setMessages] = useState<any>(null);
|
|
useEffect(() => {
|
|
(async () => {
|
|
const loadedMessages = (await import(`../messages/${locale}.json`))
|
|
.default;
|
|
setMessages(loadedMessages);
|
|
})();
|
|
}, [locale]);
|
|
return (
|
|
<html lang="en" suppressHydrationWarning className="scroll-smooth">
|
|
<head>
|
|
<meta
|
|
name="theme-color"
|
|
content="white"
|
|
media="(prefers-color-scheme: light)"
|
|
/>
|
|
<link rel="icon" href="/logohumas.png" />
|
|
<meta
|
|
name="theme-color"
|
|
content="black"
|
|
media="(prefers-color-scheme: dark)"
|
|
/>
|
|
<LoadScript />
|
|
</head>
|
|
<body
|
|
className={clsx("bg-background font-sans antialiased", inter.className)}
|
|
>
|
|
<NextIntlClientProvider locale={localeNow} messages={messages}>
|
|
<Providers themeProps={{ attribute: "class", defaultTheme: "dark" }}>
|
|
<main className="">{children}</main>
|
|
</Providers>
|
|
</NextIntlClientProvider>
|
|
</body>
|
|
</html>
|
|
);
|
|
}
|