SPB Git

Repository Public

layout.tsx 2.3 KB 45 lines tsx

1import type { Metadata, Viewport } from "next";2import type { ReactNode } from "react";3import "./globals.css";4import { getLocale } from "@/i18n/server";5import { LocaleProvider } from "@/i18n/client";6import { env } from "@/lib/env";78export async function generateMetadata(): Promise<Metadata> {9  const locale = await getLocale();10  const description = locale === "fr"11    ? "Fiches scientifiques, techniques et pédagogiques : IA, économétrie, finance, statistique, infrastructure. Diagrammes vectoriels, équations et simulations interactives."12    : "Scientific, technical and teaching sheets: AI, econometrics, finance, statistics, infrastructure. Vector diagrams, equations and interactive simulations.";13  return {14    metadataBase: new URL(env.appUrl),15    title: { default: "Sheet — by Simon-Pierre Boucher", template: "%s · Sheet" },16    description,17    applicationName: "Sheet",18    authors: [{ name: "Simon-Pierre Boucher", url: `${env.appUrl}/about` }],19    creator: "Simon-Pierre Boucher",20    manifest: "/manifest.webmanifest",21    icons: { icon: [{ url: "/icons/icon.svg", type: "image/svg+xml" }, { url: "/icons/icon-192.png", sizes: "192x192", type: "image/png" }], apple: "/icons/apple-touch-icon.png" },22    alternates: { types: { "application/rss+xml": "/rss.xml" } },23    openGraph: { siteName: "Sheet — by Simon-Pierre Boucher", type: "website", locale: locale === "fr" ? "fr_CA" : "en_CA" },24    appleWebApp: { capable: true, title: "Sheet", statusBarStyle: "default" },25  };26}2728export const viewport: Viewport = {29  width: "device-width", initialScale: 1, viewportFit: "cover",30  themeColor: [{ media: "(prefers-color-scheme: light)", color: "#fbfaf7" }, { media: "(prefers-color-scheme: dark)", color: "#0b0f17" }],31};3233// Applies the visitor's stored light/dark choice before first paint (no flash). Static text, no user input.34const MODE_SCRIPT = `try{var m=localStorage.getItem("sheet-mode");if(m==="light"||m==="dark")document.documentElement.dataset.mode=m}catch(e){}`;3536export default async function RootLayout({ children }: { children: ReactNode }) {37  const locale = await getLocale();38  return (39    <html lang={locale} suppressHydrationWarning>40      <head><script dangerouslySetInnerHTML={{ __html: MODE_SCRIPT }} /></head>41      <body><LocaleProvider locale={locale}>{children}</LocaleProvider></body>42    </html>43  );44}45
Files main
Menu

Theme