import type { Metadata } from "next"; import { cookies } from "next/headers"; import Link from "next/link"; import { notFound } from "next/navigation"; import { ForumNav } from "@/components/forum/ForumNav"; import { ThemeToggle } from "@/components/forum/ThemeToggle"; import { PublicHeader } from "@/components/SiteHeader"; import { FORUM_THEME_COOKIE, type ForumNavData, type ForumTheme } from "@/lib/forum"; import { forumEnabled, forumGet } from "@/lib/forumServer"; import "./forum.css"; export const metadata: Metadata = { title: { default: "Fórum", template: "%s · Fórum · Sorsfonalak" }, description: "Spirituális fórum a Sorsfonalakon: beszélgetés, meghallgatás, asztrológia, álmok.", }; /** * The live connection's address: in production Caddy sends `/api/v1/forum/ws` * straight to the forum service; in development FORUM_WS_URL points at it. * * The forum's frame: the visitor header (the logged-in one comes from the * root layout), the forum's bar with its menu and the light/dark switch. * Light by default; the choice lives in a cookie. */ export default async function ForumLayout({ children }: { children: React.ReactNode }) { if (!forumEnabled()) notFound(); const [nav, jar] = await Promise.all([forumGet("/v1/forum/nav"), cookies()]); const viewer = nav.ok ? nav.data.viewer : null; const theme: ForumTheme = jar.get(FORUM_THEME_COOKIE)?.value === "dark" ? "dark" : "light"; return ( <> {!viewer?.logged_in && }
Fórum
{children}
); }