mirror of
https://github.com/TheRealOwenRees/echecsfrance.git
synced 2026-11-18 07:22:06 +00:00
98 lines
2.9 KiB
TypeScript
98 lines
2.9 KiB
TypeScript
import { type ReactNode, Suspense } from "react";
|
|
|
|
import { NextIntlClientProvider } from "next-intl";
|
|
import { getTranslations } from "next-intl/server";
|
|
import { Inter, Julius_Sans_One } from "next/font/google";
|
|
import { notFound } from "next/navigation";
|
|
|
|
import { LocaleChecker } from "@/components/LocaleChecker";
|
|
import { MatomoAnalytics } from "@/components/MatomoAnalytics";
|
|
import { baseUrl } from "@/constants";
|
|
import "@/css/globals.css";
|
|
import Providers from "@/providers";
|
|
|
|
import Footer from "./(main)/components/Footer";
|
|
|
|
const inter = Inter({ subsets: ["latin"], variable: "--font-inter" });
|
|
const title = Julius_Sans_One({
|
|
subsets: ["latin"],
|
|
weight: "400",
|
|
variable: "--font-title",
|
|
});
|
|
|
|
export async function generateMetadata({ params }: { params: Promise<{ locale?: string }> }) {
|
|
// While the `locale` is required, the namespace is optional and
|
|
// identical to the parameter that `useTranslations` accepts.
|
|
const { locale } = await params;
|
|
const t = await getTranslations({
|
|
locale: locale ?? "fr",
|
|
namespace: "Metadata",
|
|
});
|
|
|
|
return {
|
|
title: t("title"),
|
|
description: t("description"),
|
|
keywords: t("keywords"),
|
|
alternates: {
|
|
canonical: locale === "fr" ? baseUrl : `${baseUrl}/${locale}`,
|
|
languages: {
|
|
fr: baseUrl,
|
|
en: `${baseUrl}/en`,
|
|
},
|
|
},
|
|
};
|
|
}
|
|
|
|
export default async function RootLayout({
|
|
children,
|
|
params,
|
|
}: {
|
|
children: ReactNode;
|
|
params: Promise<{ locale?: string }>;
|
|
}) {
|
|
const { locale } = await params;
|
|
let messages;
|
|
try {
|
|
messages = (await import(`@/messages/${locale}.json`)).default;
|
|
// oxlint-disable-next-line no-unused-vars
|
|
} catch (error) {
|
|
notFound();
|
|
}
|
|
|
|
return (
|
|
<html lang={locale} className={`${inter.variable} ${title.variable}`}>
|
|
<head>
|
|
<meta
|
|
name="viewport"
|
|
content="width=device-width, initial-scale=1, maximum-scale=5, shrink-to-fit=no, viewport-fit=cover"
|
|
/>
|
|
|
|
<meta name="application-name" content="Echecs France" />
|
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
|
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
|
|
<meta name="apple-mobile-web-app-title" content="Echecs France" />
|
|
<meta name="mobile-web-app-capable" content="yes" />
|
|
<meta name="theme-color" content="#00A1F0" />
|
|
<link rel="manifest" href="/manifest.webmanifest" />
|
|
<title>Échecs France</title>
|
|
</head>
|
|
<body>
|
|
<Providers>
|
|
<NextIntlClientProvider locale={locale} messages={messages}>
|
|
<LocaleChecker>
|
|
<div className="bg-white font-sans leading-normal tracking-normal dark:bg-gray-800">
|
|
{children}
|
|
</div>
|
|
</LocaleChecker>
|
|
<Footer />
|
|
</NextIntlClientProvider>
|
|
|
|
<Suspense fallback={null}>
|
|
<MatomoAnalytics />
|
|
</Suspense>
|
|
</Providers>
|
|
</body>
|
|
</html>
|
|
);
|
|
}
|