udpate for coming soon
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
import type { Metadata } from "next";
|
||||
import { getDictionary, type Locale } from "@/lib/i18n";
|
||||
import { getLocalizedPath, getLocalizedUrl, isComingSoonMode } from "@/lib/site";
|
||||
|
||||
type PageKey = "home" | "about" | "contact";
|
||||
|
||||
const pagePathMap: Record<PageKey, string> = {
|
||||
home: "",
|
||||
about: "/about",
|
||||
contact: "/contact",
|
||||
};
|
||||
|
||||
export function buildPageMetadata(locale: Locale, page: PageKey): Metadata {
|
||||
const dictionary = getDictionary(locale);
|
||||
const pathname = pagePathMap[page];
|
||||
const isComingSoon = isComingSoonMode();
|
||||
const metadataByPage = {
|
||||
home: {
|
||||
title: isComingSoon ? dictionary.metadata.homeTitle : dictionary.metadata.fullHomeTitle,
|
||||
description: isComingSoon ? dictionary.metadata.homeDescription : dictionary.metadata.fullHomeDescription,
|
||||
},
|
||||
about: {
|
||||
title: dictionary.metadata.aboutTitle,
|
||||
description: dictionary.metadata.aboutDescription,
|
||||
},
|
||||
contact: {
|
||||
title: dictionary.metadata.contactTitle,
|
||||
description: dictionary.metadata.contactDescription,
|
||||
},
|
||||
} as const;
|
||||
|
||||
const pageMetadata = metadataByPage[page];
|
||||
const canonicalPath = getLocalizedPath(pathname, locale);
|
||||
|
||||
return {
|
||||
title: pageMetadata.title,
|
||||
description: pageMetadata.description,
|
||||
alternates: {
|
||||
canonical: canonicalPath,
|
||||
languages: {
|
||||
ar: getLocalizedPath(pathname, "ar"),
|
||||
en: getLocalizedPath(pathname, "en"),
|
||||
"x-default": getLocalizedPath(pathname, "ar"),
|
||||
},
|
||||
},
|
||||
openGraph: {
|
||||
title: pageMetadata.title,
|
||||
description: pageMetadata.description,
|
||||
url: getLocalizedUrl(pathname, locale),
|
||||
siteName: dictionary.common.siteTitle,
|
||||
locale: locale === "ar" ? "ar_SA" : "en_US",
|
||||
type: "website",
|
||||
},
|
||||
twitter: {
|
||||
card: "summary_large_image",
|
||||
title: pageMetadata.title,
|
||||
description: pageMetadata.description,
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user