Fix Coming soon

This commit is contained in:
diyaa
2026-03-13 09:26:40 +01:00
parent 2b5e91377c
commit 0bb964f07e
16 changed files with 294 additions and 93 deletions
+24 -14
View File
@@ -1,6 +1,6 @@
import type { Metadata } from "next";
import { getDictionary, type Locale } from "@/lib/i18n";
import { getLocalizedPath, getLocalizedUrl, getModeValue } from "@/lib/site";
import { getActiveLocale, getDictionary, type Locale } from "@/lib/i18n";
import { getLocalizedPath, getLocalizedUrl, getModeValue, isComingSoonMode } from "@/lib/site";
type PageKey = "home" | "about" | "contact";
@@ -11,7 +11,8 @@ const pagePathMap: Record<PageKey, string> = {
};
export function buildPageMetadata(locale: Locale, page: PageKey): Metadata {
const dictionary = getDictionary(locale);
const activeLocale = getActiveLocale(locale);
const dictionary = getDictionary(activeLocale);
const pathname = pagePathMap[page];
const homeMetadata = getModeValue(dictionary.metadata.home);
const metadataByPage = {
@@ -30,25 +31,34 @@ export function buildPageMetadata(locale: Locale, page: PageKey): Metadata {
} as const;
const pageMetadata = metadataByPage[page];
const canonicalPath = getLocalizedPath(pathname, locale);
const canonicalPath = isComingSoonMode() && page === "home" ? "/" : getLocalizedPath(pathname, activeLocale);
const alternates = isComingSoonMode()
? {
canonical: canonicalPath,
languages: {
en: "/",
"x-default": "/",
},
}
: {
canonical: canonicalPath,
languages: {
ar: getLocalizedPath(pathname, "ar"),
en: getLocalizedPath(pathname, "en"),
"x-default": getLocalizedPath(pathname, "ar"),
},
};
return {
title: pageMetadata.title,
description: pageMetadata.description,
alternates: {
canonical: canonicalPath,
languages: {
ar: getLocalizedPath(pathname, "ar"),
en: getLocalizedPath(pathname, "en"),
"x-default": getLocalizedPath(pathname, "ar"),
},
},
alternates,
openGraph: {
title: pageMetadata.title,
description: pageMetadata.description,
url: getLocalizedUrl(pathname, locale),
url: isComingSoonMode() && page === "home" ? getLocalizedUrl("/", "en") : getLocalizedUrl(pathname, activeLocale),
siteName: dictionary.common.siteTitle,
locale: locale === "ar" ? "ar_SA" : "en_US",
locale: activeLocale === "ar" ? "ar_SA" : "en_US",
type: "website",
},
twitter: {