Files
zero-fucks-given/apps/web/app/[locale]/layout.tsx
T

50 lines
1.3 KiB
TypeScript

import type { Metadata } from 'next';
import { hasLocale, NextIntlClientProvider } from 'next-intl';
import { getMessages, getTranslations } from 'next-intl/server';
import { notFound } from 'next/navigation';
import { siteUrl } from '#web-runtime/lib/site-url';
import { routing } from '#i18n/routing';
import '../globals.css';
export async function generateMetadata({
params
}: {
params: Promise<{ locale: string }>;
}): Promise<Metadata> {
const { locale } = await params;
const t = await getTranslations({ locale, namespace: 'Metadata' });
return {
metadataBase: siteUrl(),
title: {
default: t('title'),
template: t('template')
},
description: t('description')
};
}
export default async function LocaleLayout({
children,
params
}: Readonly<{
children: React.ReactNode;
params: Promise<{ locale: string }>;
}>) {
const { locale } = await params;
if (!hasLocale(routing.locales, locale)) {
notFound();
}
const messages = await getMessages();
return (
<html lang={locale} className="scroll-smooth bg-[#f4f1e9] motion-reduce:scroll-auto">
<body className="min-h-dvh bg-[#f4f1e9] font-sans text-[#172019] antialiased">
<NextIntlClientProvider messages={messages}>{children}</NextIntlClientProvider>
</body>
</html>
);
}