feat: build production-ready wtr weather PWA
This commit is contained in:
50
app/layout.tsx
Normal file
50
app/layout.tsx
Normal file
@@ -0,0 +1,50 @@
|
||||
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/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 {}
|
||||
`;
|
||||
|
||||
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: "#e8f4fb" },
|
||||
{ media: "(prefers-color-scheme: dark)", color: "#07111f" },
|
||||
],
|
||||
};
|
||||
|
||||
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>
|
||||
<Providers>
|
||||
<AppShell>{children}</AppShell>
|
||||
</Providers>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user