58 lines
2.1 KiB
TypeScript
58 lines
2.1 KiB
TypeScript
import type { Metadata, Viewport } from "next";
|
|
import { Inter } from "next/font/google";
|
|
import Script from "next/script";
|
|
import { AppShell } from "@/components/layout/app-shell";
|
|
import { Providers } from "@/components/layout/providers";
|
|
import { APP_THEME_COLORS } from "@/lib/theme";
|
|
import "@/app/globals.css";
|
|
|
|
const inter = Inter({ subsets: ["latin", "latin-ext"], variable: "--font-inter" });
|
|
const themeScript = `
|
|
try {
|
|
const storedTheme = localStorage.getItem("wtr:theme");
|
|
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
document.documentElement.classList.toggle("dark", storedTheme ? storedTheme === "dark" : prefersDark);
|
|
} catch {}
|
|
`;
|
|
const languageScript = `
|
|
try {
|
|
document.documentElement.lang = localStorage.getItem("wtr:language") === "en" ? "en" : "pl";
|
|
} catch {}
|
|
`;
|
|
|
|
export const metadata: Metadata = {
|
|
title: { default: "wtr. | Pogoda z danych IMGW", template: "%s | wtr." },
|
|
description: "wtr. to nowoczesna pogodowa PWA dla Polski oparta o publiczne dane IMGW.",
|
|
applicationName: "wtr.",
|
|
manifest: "/manifest.json",
|
|
appleWebApp: { capable: true, statusBarStyle: "black-translucent", title: "wtr." },
|
|
icons: {
|
|
icon: [{ url: "/icons/icon.svg", type: "image/svg+xml" }, { url: "/icons/icon-192.png", sizes: "192x192", type: "image/png" }],
|
|
apple: "/icons/icon-192.png",
|
|
},
|
|
};
|
|
|
|
export const viewport: Viewport = {
|
|
width: "device-width",
|
|
initialScale: 1,
|
|
viewportFit: "cover",
|
|
themeColor: [
|
|
{ media: "(prefers-color-scheme: light)", color: APP_THEME_COLORS.light },
|
|
{ media: "(prefers-color-scheme: dark)", color: APP_THEME_COLORS.dark },
|
|
],
|
|
};
|
|
|
|
export default function RootLayout({ children }: Readonly<{ children: React.ReactNode }>) {
|
|
return (
|
|
<html lang="pl" suppressHydrationWarning data-scroll-behavior="smooth">
|
|
<body className={`${inter.variable} font-sans`}>
|
|
<Script id="wtr-theme" strategy="beforeInteractive">{themeScript}</Script>
|
|
<Script id="wtr-language" strategy="beforeInteractive">{languageScript}</Script>
|
|
<Providers>
|
|
<AppShell>{children}</AppShell>
|
|
</Providers>
|
|
</body>
|
|
</html>
|
|
);
|
|
}
|