8dccd8898b
Language switcher (flag toggle) and dark-mode toggle in the marketing header, both usable by logged-out visitors -- the marketing pages previously hardcoded English (getMessages(undefined)) regardless of any preference, and had no theme control since the authenticated Nav's toggle isn't rendered there. New cookie-based locale resolution (lib/marketing-locale.ts) separate from the authenticated app's useLocale/setLocale, which persists via an authenticated PATCH that would just 401 and revert for an anonymous visitor. Root layout now falls back to that cookie for <html lang> when there's no session. Features/Home now cover cook mode, recipe variations, personalized recommendations, and ingredient substitution -- all real, shipped features that were missing from the page copy. Signup CTAs check isSignupsDisabled() and swap to "Signups closed" instead of "Get started free" -- still linking to /signup, since that page already handles the invite-token exception correctly. Fixed along the way: importing the cookie-name constant from marketing-locale.ts in the client-side LanguageSwitcher pulled that file's server-only imports (lib/auth/server -> the DB client -> `postgres`) into the client bundle, breaking the build on Node built-ins. Split the constant into its own client-safe file (marketing-locale-cookie.ts). Caught by `pnpm build`, not typecheck. Verified with typecheck, lint, and a full production build (clean compile) -- no DB in this sandbox to click through a real dev server. v0.48.1
54 lines
1.6 KiB
TypeScript
54 lines
1.6 KiB
TypeScript
import type { Metadata, Viewport } from "next";
|
|
import { Lora, Geist_Mono } from "next/font/google";
|
|
import { headers } from "next/headers";
|
|
import { Providers } from "@/components/providers";
|
|
import { auth } from "@/lib/auth/server";
|
|
import type { Locale } from "@/lib/i18n/provider";
|
|
import { SwRegister } from "@/components/pwa/sw-register";
|
|
import { getMarketingLocale } from "@/lib/marketing-locale";
|
|
import "./globals.css";
|
|
|
|
const lora = Lora({
|
|
variable: "--font-lora",
|
|
subsets: ["latin"],
|
|
display: "swap",
|
|
});
|
|
|
|
const geistMono = Geist_Mono({
|
|
variable: "--font-geist-mono",
|
|
subsets: ["latin"],
|
|
});
|
|
|
|
export const metadata: Metadata = {
|
|
title: "Epicure",
|
|
description: "Your personal AI-powered recipe book.",
|
|
manifest: "/manifest.json",
|
|
};
|
|
|
|
export const viewport: Viewport = {
|
|
themeColor: "#18181b",
|
|
};
|
|
|
|
export default async function RootLayout({
|
|
children,
|
|
}: Readonly<{ children: React.ReactNode }>) {
|
|
const session = await auth.api.getSession({ headers: await headers() }).catch(() => null);
|
|
// Signed-in users: their saved preference. Anonymous visitors (marketing
|
|
// pages): the marketing-locale cookie instead, since there's no account to
|
|
// read a preference from.
|
|
const initialLocale = ((session?.user as { locale?: string })?.locale ?? await getMarketingLocale()) as Locale;
|
|
|
|
return (
|
|
<html
|
|
lang={initialLocale}
|
|
suppressHydrationWarning
|
|
className={`${lora.variable} ${geistMono.variable} h-full antialiased`}
|
|
>
|
|
<body className="min-h-full flex flex-col">
|
|
<Providers initialLocale={initialLocale}>{children}</Providers>
|
|
<SwRegister />
|
|
</body>
|
|
</html>
|
|
);
|
|
}
|