Files
sorsfonalak/services/frontend/src/app/forum/layout.tsx
T
fecoandClaude Opus 5.5 9ca3f478be Forum: search, muting members, archived topics, the public threads in the sitemap
- Search (/forum/kereses, the magnifier in the forum bar): thread titles
  and posts the viewer may read, Hungarian stems and word beginnings
  without accents ("alvas" finds "alvásban"), one result per thread with
  the matching words marked.
- Muting a member (post menu, profile; the list in the settings): their
  threads leave the lists, their posts fold up, their replies and mentions
  no longer count or send e-mails. They are not told.
- The admin archives a topic (Moderálás → Témák): it stays readable but
  takes no new threads or replies, and folds away on the front page.
- The public topics and threads are in the sitemap; the forum's own pages
  are kept from robots.
- A reply e-mail goes to the one answered, also on the second level.
- Migration 0043 also prepares charts attached to a forum question.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
2026-11-26 14:31:05 +00:00

67 lines
2.7 KiB
TypeScript

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<ForumNavData>("/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 && <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}
initial={{
replies: nav.ok ? (nav.data.replies ?? 0) : 0,
messages: nav.ok ? (nav.data.messages ?? 0) : 0,
reports: nav.ok ? (nav.data.reports ?? 0) : 0,
}}
wsUrl={process.env.FORUM_WS_URL || "/api/v1/forum/ws"}
/>
<div className="forum-tools">
<Link href="/forum/kereses" className="forum-theme forum-search" aria-label="Keresés a fórumban">
<svg viewBox="0 0 24 24" aria-hidden="true">
<circle cx="11" cy="11" r="6.5" />
<path d="M16 16l4.5 4.5" />
</svg>
</Link>
<ThemeToggle initial={theme} />
</div>
</div>
<main className="forum-main">{children}</main>
</div>
</div>
</>
);
}