2026-11-26 10:29:49 +00:00
|
|
|
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";
|
2026-11-26 10:48:28 +00:00
|
|
|
import { FORUM_THEME_COOKIE, type ForumNavData, type ForumTheme } from "@/lib/forum";
|
2026-11-26 10:29:49 +00:00
|
|
|
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 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();
|
2026-11-26 10:48:28 +00:00
|
|
|
const [nav, jar] = await Promise.all([forumGet<ForumNavData>("/v1/forum/nav"), cookies()]);
|
2026-11-26 10:29:49 +00:00
|
|
|
const viewer = nav.ok ? nav.data.viewer : null;
|
|
|
|
|
const theme: ForumTheme = jar.get(FORUM_THEME_COOKIE)?.value === "dark" ? "dark" : "light";
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
{!viewer?.logged_in && <PublicHeader current="forum" />}
|
|
|
|
|
<div className="forum" data-theme={theme}>
|
|
|
|
|
<div className="forum-inner">
|
|
|
|
|
<div className="forum-bar">
|
|
|
|
|
<Link href="/forum" className="forum-mark">
|
|
|
|
|
Fórum
|
|
|
|
|
</Link>
|
|
|
|
|
<ForumNav
|
|
|
|
|
member={viewer?.member?.nickname ?? null}
|
|
|
|
|
loggedIn={viewer?.logged_in ?? false}
|
|
|
|
|
unread={nav.ok ? (nav.data.followed?.new_replies ?? 0) : 0}
|
2026-11-26 10:48:28 +00:00
|
|
|
messages={nav.ok ? (nav.data.messages ?? 0) : 0}
|
2026-11-26 10:29:49 +00:00
|
|
|
/>
|
2026-11-26 10:48:28 +00:00
|
|
|
{nav.ok && nav.data.reports ? (
|
|
|
|
|
<Link href="/forum/moderalas" className="forum-modchip">
|
|
|
|
|
Jelentés: {nav.data.reports}
|
|
|
|
|
</Link>
|
|
|
|
|
) : null}
|
2026-11-26 10:29:49 +00:00
|
|
|
<ThemeToggle initial={theme} />
|
|
|
|
|
</div>
|
|
|
|
|
<main className="forum-main">{children}</main>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|