Fix Coming soon
This commit is contained in:
+41
-23
@@ -1,31 +1,46 @@
|
||||
import type { Metadata } from "next";
|
||||
import type { ReactNode } from "react";
|
||||
import { siteConfig } from "@/lib/site";
|
||||
import { isComingSoonMode } from "@/lib/site";
|
||||
import "./globals.css";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
metadataBase: new URL(siteConfig.siteUrl),
|
||||
title: {
|
||||
default: "Diyaa",
|
||||
template: "%s | Diyaa",
|
||||
},
|
||||
description: "Bilingual professional website built for private-server deployment.",
|
||||
applicationName: "Diyaa",
|
||||
authors: [{ name: "Diyaa" }],
|
||||
creator: "Diyaa",
|
||||
publisher: "Diyaa",
|
||||
alternates: {
|
||||
languages: {
|
||||
ar: "/ar",
|
||||
en: "/en",
|
||||
"x-default": "/ar",
|
||||
},
|
||||
},
|
||||
};
|
||||
export function generateMetadata(): Metadata {
|
||||
const comingSoon = isComingSoonMode();
|
||||
|
||||
const themeScript = `
|
||||
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 = window.location.pathname.split("/").filter(Boolean)[0] === "en" ? "en" : "ar";
|
||||
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;
|
||||
@@ -38,12 +53,15 @@ const themeScript = `
|
||||
}
|
||||
})();
|
||||
`;
|
||||
}
|
||||
|
||||
export default function RootLayout({ children }: { children: ReactNode }) {
|
||||
const comingSoon = isComingSoonMode();
|
||||
|
||||
return (
|
||||
<html lang="ar" dir="rtl" data-theme="dark" suppressHydrationWarning>
|
||||
<html lang={comingSoon ? "en" : "ar"} dir={comingSoon ? "ltr" : "rtl"} data-theme="dark" suppressHydrationWarning>
|
||||
<head>
|
||||
<script dangerouslySetInnerHTML={{ __html: themeScript }} />
|
||||
<script dangerouslySetInnerHTML={{ __html: getThemeScript() }} />
|
||||
</head>
|
||||
<body>{children}</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user