76 lines
2.6 KiB
TypeScript
76 lines
2.6 KiB
TypeScript
import type { Metadata } from "next";
|
||
import localFont from "next/font/local";
|
||
import { Suspense } from "react";
|
||
import MobileBottomNav from "@/components/MobileBottomNav";
|
||
import Navbar from "@/components/Navbar";
|
||
import Footer from "@/components/Footer";
|
||
import Providers from "@/components/providers";
|
||
import RouteProgress from "@/components/RouteProgress";
|
||
import { getCmsSiteContent } from "@/lib/content-cms";
|
||
import { siteUrl } from "@/lib/site";
|
||
import "../index.css";
|
||
|
||
const vazirmatn = localFont({
|
||
src: "./fonts/Vazirmatn-variable.woff2",
|
||
display: "swap",
|
||
weight: "100 900",
|
||
variable: "--font-vazirmatn",
|
||
fallback: ["Tahoma", "Arial", "sans-serif"],
|
||
});
|
||
|
||
export async function generateMetadata(): Promise<Metadata> {
|
||
const siteContent = await getCmsSiteContent();
|
||
const title = siteContent.seo.title || siteContent.official_name;
|
||
const description = siteContent.seo.description || siteContent.description;
|
||
const image = siteContent.seo.image?.url || siteContent.logo?.url || `${siteUrl}/favicon.ico`;
|
||
|
||
return {
|
||
metadataBase: new URL(siteUrl),
|
||
title: {
|
||
default: title,
|
||
template: `%s | ${siteContent.short_name || siteContent.official_name}`,
|
||
},
|
||
description,
|
||
openGraph: {
|
||
siteName: siteContent.official_name,
|
||
images: [image],
|
||
locale: "fa_IR",
|
||
type: "website",
|
||
},
|
||
};
|
||
}
|
||
|
||
export default async function RootLayout({
|
||
children,
|
||
}: Readonly<{
|
||
children: React.ReactNode;
|
||
}>) {
|
||
const siteContent = await getCmsSiteContent();
|
||
|
||
return (
|
||
<html lang="fa" dir="rtl" suppressHydrationWarning>
|
||
<body className={`${vazirmatn.variable} flex min-h-svh flex-col font-sans antialiased`}>
|
||
<Providers>
|
||
<a
|
||
href="#main-content"
|
||
className="sr-only focus:not-sr-only focus:absolute focus:right-4 focus:top-4 focus:z-[100] focus:rounded-lg focus:bg-background focus:px-4 focus:py-3 focus:font-semibold focus:text-foreground focus:shadow-lg focus:outline-none focus:ring-2 focus:ring-ring"
|
||
>
|
||
رفتن به محتوای اصلی
|
||
</a>
|
||
<Suspense fallback={null}>
|
||
<RouteProgress />
|
||
</Suspense>
|
||
<Navbar siteContent={siteContent} />
|
||
<div className="flex min-h-[calc(100svh-4.5rem)] flex-1 flex-col pb-28 md:pb-0">
|
||
<div id="main-content" tabIndex={-1} className="flex-1 outline-none">
|
||
{children}
|
||
</div>
|
||
</div>
|
||
<Footer siteContent={siteContent} />
|
||
<MobileBottomNav siteContent={siteContent} />
|
||
</Providers>
|
||
</body>
|
||
</html>
|
||
);
|
||
}
|