70 lines
2.0 KiB
TypeScript
70 lines
2.0 KiB
TypeScript
import type { Metadata } from "next";
|
|
import type { ReactNode } from "react";
|
|
import { siteConfig } from "@/lib/site";
|
|
import { isComingSoonMode } from "@/lib/site";
|
|
import "./globals.css";
|
|
|
|
export function generateMetadata(): Metadata {
|
|
const comingSoon = isComingSoonMode();
|
|
|
|
return {
|
|
metadataBase: new URL(siteConfig.siteUrl),
|
|
title: {
|
|
default: "Diyaa",
|
|
template: "%s | Diyaa",
|
|
},
|
|
description: comingSoon
|
|
? "Minimal coming soon page for the upcoming launch."
|
|
: "Bilingual professional website built for private-server deployment.",
|
|
applicationName: "Diyaa",
|
|
authors: [{ name: "Diyaa" }],
|
|
creator: "Diyaa",
|
|
publisher: "Diyaa",
|
|
alternates: {
|
|
languages: comingSoon
|
|
? {
|
|
en: "/",
|
|
"x-default": "/",
|
|
}
|
|
: {
|
|
ar: "/ar",
|
|
en: "/en",
|
|
"x-default": "/ar",
|
|
},
|
|
},
|
|
};
|
|
}
|
|
|
|
function getThemeScript() {
|
|
const comingSoon = isComingSoonMode();
|
|
|
|
return `
|
|
(() => {
|
|
const locale = ${comingSoon ? '"en"' : 'window.location.pathname.split("/").filter(Boolean)[0] === "en" ? "en" : "ar"'};
|
|
const direction = locale === "ar" ? "rtl" : "ltr";
|
|
document.documentElement.lang = locale;
|
|
document.documentElement.dir = direction;
|
|
try {
|
|
const storedTheme = localStorage.getItem("theme");
|
|
const activeTheme = storedTheme === "light" || storedTheme === "dark" ? storedTheme : "dark";
|
|
document.documentElement.setAttribute("data-theme", activeTheme);
|
|
} catch {
|
|
document.documentElement.setAttribute("data-theme", "dark");
|
|
}
|
|
})();
|
|
`;
|
|
}
|
|
|
|
export default function RootLayout({ children }: { children: ReactNode }) {
|
|
const comingSoon = isComingSoonMode();
|
|
|
|
return (
|
|
<html lang={comingSoon ? "en" : "ar"} dir={comingSoon ? "ltr" : "rtl"} data-theme="dark" suppressHydrationWarning>
|
|
<head>
|
|
<script dangerouslySetInnerHTML={{ __html: getThemeScript() }} />
|
|
</head>
|
|
<body>{children}</body>
|
|
</html>
|
|
);
|
|
}
|