feat: complete initial project setup with i18n and standalone config
This commit is contained in:
66
app/[locale]/layout.tsx
Normal file
66
app/[locale]/layout.tsx
Normal file
@@ -0,0 +1,66 @@
|
||||
import type { Metadata } from "next";
|
||||
import { Cormorant_Garamond, Oswald } from "next/font/google";
|
||||
import "../globals.css";
|
||||
import { NextIntlClientProvider } from 'next-intl';
|
||||
import { getMessages, getTranslations } from 'next-intl/server';
|
||||
import { notFound } from 'next/navigation';
|
||||
import { routing } from '@/i18n/routing';
|
||||
|
||||
const cormorant = Cormorant_Garamond({
|
||||
subsets: ["latin", "latin-ext"],
|
||||
weight: ["300", "400", "500", "600", "700"],
|
||||
variable: "--font-serif",
|
||||
display: 'swap',
|
||||
});
|
||||
|
||||
const oswald = Oswald({
|
||||
subsets: ["latin", "latin-ext"],
|
||||
variable: "--font-sans",
|
||||
display: 'swap',
|
||||
});
|
||||
|
||||
export async function generateMetadata({
|
||||
params
|
||||
}: {
|
||||
params: Promise<{ locale: string }>
|
||||
}): Promise<Metadata> {
|
||||
const { locale } = await params;
|
||||
const t = await getTranslations({ locale, namespace: 'Index' });
|
||||
|
||||
return {
|
||||
title: {
|
||||
default: t('title') + " | Salmakis Villas",
|
||||
template: "%s | Salmakis Villas"
|
||||
},
|
||||
description: t('description'),
|
||||
};
|
||||
}
|
||||
|
||||
export default async function RootLayout({
|
||||
children,
|
||||
params
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
params: Promise<{ locale: string }>;
|
||||
}) {
|
||||
const { locale } = await params;
|
||||
|
||||
// Ensure that the incoming `locale` is valid
|
||||
if (!routing.locales.includes(locale as "en" | "tr")) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
// Providing all messages to the client
|
||||
// side is the easiest way to get started
|
||||
const messages = await getMessages();
|
||||
|
||||
return (
|
||||
<html lang={locale} className={`${cormorant.variable} ${oswald.variable} scroll-smooth`}>
|
||||
<body className="font-sans bg-bone text-aegean-dark min-h-screen flex flex-col">
|
||||
<NextIntlClientProvider messages={messages}>
|
||||
{children}
|
||||
</NextIntlClientProvider>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user