Fix runttime
This commit is contained in:
parent
d1ed5c641b
commit
c9e9ae6b90
@ -1,7 +1,7 @@
|
||||
import Link from "next/link";
|
||||
import type { CommonContent, HomeContent, HomeVariantContent } from "@/content/types";
|
||||
import type { Locale } from "@/lib/i18n";
|
||||
import { getEmailHref, isComingSoonMode } from "@/lib/site";
|
||||
import { getEmailHref, getModeValue, isComingSoonMode } from "@/lib/site";
|
||||
|
||||
type HeroSectionProps = {
|
||||
locale: Locale;
|
||||
@ -10,7 +10,7 @@ type HeroSectionProps = {
|
||||
};
|
||||
|
||||
export default function HeroSection({ locale, home, common }: HeroSectionProps) {
|
||||
const activeHome: HomeVariantContent = isComingSoonMode() ? home.comingSoon : home.full;
|
||||
const activeHome: HomeVariantContent = getModeValue(home);
|
||||
const emailHref = getEmailHref();
|
||||
|
||||
return (
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import type { Locale } from "@/lib/i18n";
|
||||
import type { CommonContent } from "@/content/types";
|
||||
import { getModeValue } from "@/lib/site";
|
||||
|
||||
type SiteFooterProps = {
|
||||
locale: Locale;
|
||||
@ -8,13 +9,14 @@ type SiteFooterProps = {
|
||||
|
||||
export default function SiteFooter({ locale, common }: SiteFooterProps) {
|
||||
const year = new Date().getFullYear();
|
||||
const commonVariant = getModeValue(common.variants);
|
||||
|
||||
return (
|
||||
<footer className="site-footer">
|
||||
<div className="container footer-content">
|
||||
<div className="footer-copy">
|
||||
<p>{common.footerRights.replace("{year}", String(year))}</p>
|
||||
<p>{common.footerBuiltWith}</p>
|
||||
<p>{commonVariant.footerBuiltWith}</p>
|
||||
</div>
|
||||
<p className="locale-badge">{locale.toUpperCase()}</p>
|
||||
</div>
|
||||
|
||||
@ -3,7 +3,7 @@ import LanguageSwitcher from "@/components/LanguageSwitcher";
|
||||
import ThemeToggle from "@/components/ThemeToggle";
|
||||
import type { Locale } from "@/lib/i18n";
|
||||
import type { CommonContent } from "@/content/types";
|
||||
import { isComingSoonMode } from "@/lib/site";
|
||||
import { getModeValue, isComingSoonMode } from "@/lib/site";
|
||||
|
||||
type SiteHeaderProps = {
|
||||
locale: Locale;
|
||||
@ -12,6 +12,7 @@ type SiteHeaderProps = {
|
||||
|
||||
export default function SiteHeader({ locale, common }: SiteHeaderProps) {
|
||||
const isComingSoon = isComingSoonMode();
|
||||
const commonVariant = getModeValue(common.variants);
|
||||
|
||||
return (
|
||||
<header className="site-header">
|
||||
@ -20,7 +21,7 @@ export default function SiteHeader({ locale, common }: SiteHeaderProps) {
|
||||
<Link href={`/${locale}`} className="brand">
|
||||
{common.siteTitle}
|
||||
</Link>
|
||||
<span className="brand-tagline">{common.siteTagline}</span>
|
||||
<span className="brand-tagline">{commonVariant.siteTagline}</span>
|
||||
</div>
|
||||
|
||||
{!isComingSoon ? (
|
||||
|
||||
@ -3,7 +3,6 @@ import type { Dictionary } from "@/content/types";
|
||||
const ar: Dictionary = {
|
||||
common: {
|
||||
siteTitle: "ضياء",
|
||||
siteTagline: "موقع شخصي جديد قيد الإطلاق",
|
||||
navLabel: "التنقل الرئيسي",
|
||||
languageSwitcherLabel: "تبديل اللغة",
|
||||
themeToggleLabel: "نمط الواجهة",
|
||||
@ -15,8 +14,16 @@ const ar: Dictionary = {
|
||||
contact: "تواصل",
|
||||
},
|
||||
footerRights: "{year} جميع الحقوق محفوظة",
|
||||
variants: {
|
||||
comingSoon: {
|
||||
siteTagline: "موقع شخصي جديد قيد الإطلاق",
|
||||
footerBuiltWith: "صفحة مؤقتة للإعلان عن قرب إطلاق الموقع الكامل على الخادم الخاص.",
|
||||
},
|
||||
full: {
|
||||
siteTagline: "مطور ويب يبني تجارب سريعة وقابلة للتوسع",
|
||||
footerBuiltWith: "موقع ثنائي اللغة مهيأ للعرض المهني والنشر على خادم خاص.",
|
||||
availabilityBadge: "متاح لمشاريع الويب والتطوير المخصص",
|
||||
},
|
||||
},
|
||||
},
|
||||
home: {
|
||||
comingSoon: {
|
||||
@ -92,10 +99,16 @@ const ar: Dictionary = {
|
||||
],
|
||||
},
|
||||
metadata: {
|
||||
homeTitle: "قريبًا",
|
||||
homeDescription: "صفحة ترحيبية مؤقتة للإعلان عن قرب إطلاق الموقع الشخصي الجديد.",
|
||||
fullHomeTitle: "الصفحة الرئيسية",
|
||||
fullHomeDescription: "موقع شخصي احترافي ثنائي اللغة يعرض الهوية المهنية والخبرة التقنية والاستعداد للنشر.",
|
||||
home: {
|
||||
comingSoon: {
|
||||
title: "قريبًا",
|
||||
description: "صفحة ترحيبية مؤقتة للإعلان عن قرب إطلاق الموقع الشخصي الجديد.",
|
||||
},
|
||||
full: {
|
||||
title: "الصفحة الرئيسية",
|
||||
description: "موقع شخصي احترافي ثنائي اللغة يعرض الهوية المهنية والخبرة التقنية والاستعداد للنشر.",
|
||||
},
|
||||
},
|
||||
aboutTitle: "من أنا",
|
||||
aboutDescription: "تعرف على الخبرات، المهارات، ومنهج العمل في بناء مواقع وأنظمة ويب حديثة.",
|
||||
contactTitle: "تواصل",
|
||||
|
||||
@ -3,7 +3,6 @@ import type { Dictionary } from "@/content/types";
|
||||
const en: Dictionary = {
|
||||
common: {
|
||||
siteTitle: "Diyaa",
|
||||
siteTagline: "A new personal site is on the way",
|
||||
navLabel: "Main navigation",
|
||||
languageSwitcherLabel: "Switch language",
|
||||
themeToggleLabel: "Interface theme",
|
||||
@ -15,8 +14,16 @@ const en: Dictionary = {
|
||||
contact: "Contact",
|
||||
},
|
||||
footerRights: "{year} All rights reserved",
|
||||
variants: {
|
||||
comingSoon: {
|
||||
siteTagline: "A new personal site is on the way",
|
||||
footerBuiltWith: "A temporary landing page announcing the upcoming launch on the private server.",
|
||||
},
|
||||
full: {
|
||||
siteTagline: "Web developer building fast, scalable digital experiences",
|
||||
footerBuiltWith: "A bilingual professional site prepared for deployment on a private server.",
|
||||
availabilityBadge: "Available for web builds and custom development",
|
||||
},
|
||||
},
|
||||
},
|
||||
home: {
|
||||
comingSoon: {
|
||||
@ -92,10 +99,16 @@ const en: Dictionary = {
|
||||
],
|
||||
},
|
||||
metadata: {
|
||||
homeTitle: "Coming Soon",
|
||||
homeDescription: "A temporary landing page announcing the upcoming launch of the new personal website.",
|
||||
fullHomeTitle: "Home",
|
||||
fullHomeDescription: "A bilingual professional site presenting technical expertise, project readiness, and server-friendly deployment.",
|
||||
home: {
|
||||
comingSoon: {
|
||||
title: "Coming Soon",
|
||||
description: "A temporary landing page announcing the upcoming launch of the new personal website.",
|
||||
},
|
||||
full: {
|
||||
title: "Home",
|
||||
description: "A bilingual professional site presenting technical expertise, project readiness, and server-friendly deployment.",
|
||||
},
|
||||
},
|
||||
aboutTitle: "About",
|
||||
aboutDescription: "Learn about experience, skills, and the working approach behind modern web builds.",
|
||||
contactTitle: "Contact",
|
||||
|
||||
@ -1,6 +1,15 @@
|
||||
export type ModeVariants<T> = {
|
||||
comingSoon: T;
|
||||
full: T;
|
||||
};
|
||||
|
||||
export type CommonVariantContent = {
|
||||
siteTagline: string;
|
||||
footerBuiltWith: string;
|
||||
};
|
||||
|
||||
export type CommonContent = {
|
||||
siteTitle: string;
|
||||
siteTagline: string;
|
||||
navLabel: string;
|
||||
languageSwitcherLabel: string;
|
||||
themeToggleLabel: string;
|
||||
@ -12,8 +21,7 @@ export type CommonContent = {
|
||||
contact: string;
|
||||
};
|
||||
footerRights: string;
|
||||
footerBuiltWith: string;
|
||||
availabilityBadge: string;
|
||||
variants: ModeVariants<CommonVariantContent>;
|
||||
};
|
||||
|
||||
export type HomeVariantContent = {
|
||||
@ -29,10 +37,7 @@ export type HomeVariantContent = {
|
||||
}>;
|
||||
};
|
||||
|
||||
export type HomeContent = {
|
||||
comingSoon: HomeVariantContent;
|
||||
full: HomeVariantContent;
|
||||
};
|
||||
export type HomeContent = ModeVariants<HomeVariantContent>;
|
||||
|
||||
export type AboutContent = {
|
||||
kicker: string;
|
||||
@ -64,11 +69,13 @@ export type ContactContent = {
|
||||
channels: ContactChannelContent[];
|
||||
};
|
||||
|
||||
export type MetadataVariantContent = {
|
||||
title: string;
|
||||
description: string;
|
||||
};
|
||||
|
||||
export type MetadataContent = {
|
||||
homeTitle: string;
|
||||
homeDescription: string;
|
||||
fullHomeTitle: string;
|
||||
fullHomeDescription: string;
|
||||
home: ModeVariants<MetadataVariantContent>;
|
||||
aboutTitle: string;
|
||||
aboutDescription: string;
|
||||
contactTitle: string;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import type { Metadata } from "next";
|
||||
import { getDictionary, type Locale } from "@/lib/i18n";
|
||||
import { getLocalizedPath, getLocalizedUrl, isComingSoonMode } from "@/lib/site";
|
||||
import { getLocalizedPath, getLocalizedUrl, getModeValue } from "@/lib/site";
|
||||
|
||||
type PageKey = "home" | "about" | "contact";
|
||||
|
||||
@ -13,11 +13,11 @@ const pagePathMap: Record<PageKey, string> = {
|
||||
export function buildPageMetadata(locale: Locale, page: PageKey): Metadata {
|
||||
const dictionary = getDictionary(locale);
|
||||
const pathname = pagePathMap[page];
|
||||
const isComingSoon = isComingSoonMode();
|
||||
const homeMetadata = getModeValue(dictionary.metadata.home);
|
||||
const metadataByPage = {
|
||||
home: {
|
||||
title: isComingSoon ? dictionary.metadata.homeTitle : dictionary.metadata.fullHomeTitle,
|
||||
description: isComingSoon ? dictionary.metadata.homeDescription : dictionary.metadata.fullHomeDescription,
|
||||
title: homeMetadata.title,
|
||||
description: homeMetadata.description,
|
||||
},
|
||||
about: {
|
||||
title: dictionary.metadata.aboutTitle,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import type { ContactContent } from "@/content/types";
|
||||
import type { ContactContent, ModeVariants } from "@/content/types";
|
||||
|
||||
const FALLBACK_SITE_URL = "https://example.com";
|
||||
const SITE_MODES = ["coming-soon", "full"] as const;
|
||||
@ -60,6 +60,10 @@ export function isComingSoonMode(): boolean {
|
||||
return getSiteMode() === "coming-soon";
|
||||
}
|
||||
|
||||
export function getModeValue<T>(variants: ModeVariants<T>): T {
|
||||
return variants[getSiteMode()];
|
||||
}
|
||||
|
||||
export function getLocalizedPath(pathname: string, locale: "ar" | "en"): string {
|
||||
const normalizedPath = pathname === "/" ? "" : pathname;
|
||||
return `/${locale}${normalizedPath}`;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user