Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/app/[lang]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ import { ThemeProvider } from "@/components/atom/theme-provider";
import { ImageKitProvider } from "@/components/ui/imagekit-provider";
import { Toaster } from "sonner";
import { getDictionary } from "@/components/internationalization/dictionaries";
import { type Locale, localeConfig } from "@/components/internationalization/config";
import { i18n, type Locale, localeConfig } from "@/components/internationalization/config";
import { SessionProvider } from "next-auth/react";
import { auth } from "@/auth";

function resolveLocale(rawLang: string): Locale {
return (i18n.locales as readonly string[]).includes(rawLang)
? (rawLang as Locale)
: i18n.defaultLocale;
}

// Configure Rubik font for Arabic
const rubik = Rubik({
subsets: ['arabic', 'latin'],
Expand All @@ -29,9 +35,10 @@ export const viewport: Viewport = {
export async function generateMetadata({
params,
}: {
params: Promise<{ lang: Locale }>;
params: Promise<{ lang: string }>;
}): Promise<Metadata> {
const { lang } = await params;
const { lang: rawLang } = await params;
const lang = resolveLocale(rawLang);
const dict = await getDictionary(lang);
const baseUrl = process.env.NEXT_PUBLIC_BASE_URL || 'https://databayt.org';

Expand Down Expand Up @@ -78,9 +85,10 @@ export default async function LocaleLayout({
params,
}: Readonly<{
children: React.ReactNode;
params: Promise<{ lang: Locale }>;
params: Promise<{ lang: string }>;
}>) {
const [{ lang }, session] = await Promise.all([params, auth()]);
const [{ lang: rawLang }, session] = await Promise.all([params, auth()]);
const lang = resolveLocale(rawLang);
const config = localeConfig[lang];
const isRTL = config.dir === 'rtl';

Expand Down