Forum: thread cards with the start of the opening post, latest threads and pinned threads on the front page
CI / test (push) Successful in 3m19s
CI / build (push) Skipped
CI / deploy (push) Skipped

- Every thread card shows the start of the opening post (two lines on a
  computer, three on a phone), its topic with the icon (a lock for
  members-only and restricted ones), pinned and the wish; the replies, the
  last activity and what is new on the right (in the bottom line on a
  phone). The same card in topics, search and followed threads.
- The front page: "Legutóbbi szálak" below the topics, from every topic
  the viewer may read (not the archived ones), the latest activity first,
  20 a page with a pager; pinned threads in "Kitűzve" above the topics.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-26 18:15:43 +00:00
co-authored by Claude Opus 5.5
parent 46a2b6781e
commit 8150247503
9 changed files with 213 additions and 48 deletions
+19
View File
@@ -786,3 +786,22 @@ a.fh-online-item:hover { color: var(--gold); }
display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
padding: 10px 12px 10px 18px; border-top: 1px solid var(--line); background: var(--f-tint);
}
/* --- thread cards with the start of the opening post --- */
.ft-row { align-items: flex-start; }
.ft-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 13px; color: var(--ink-2); }
.ft-topic { display: inline-flex; align-items: center; gap: 5px; }
.ft-topic .topic-icon { width: 14px; height: 14px; }
.ft-lock { width: 11px; height: 11px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.ft-row .ft-excerpt { font-size: 14.5px; line-height: 1.5; -webkit-line-clamp: 3; }
.ft-meta { flex-wrap: wrap; font-size: 13px; }
.ft-who { color: var(--ink); font-weight: 500; }
.ft-m-new { margin-left: auto; }
.ft-side { display: none; }
@media (min-width: 760px) {
.ft-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px; gap: 0 24px; padding: 16px 20px; align-items: center; }
.ft-row .ft-excerpt { font-size: 15px; -webkit-line-clamp: 2; }
.ft-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; font-size: 15px; color: var(--ink); }
.ft-side .hint { font-size: 13px; }
.ft-side strong { font-weight: 600; }
}
+39 -3
View File
@@ -8,7 +8,7 @@ import { TopicIcon } from "@/components/forum/TopicIcon";
import { ThreadList, WaitingCard } from "@/components/forum/ThreadList";
import { MoonPhaseIcon } from "@/components/MoonChip";
import { MOON_PHASES, SIGNS } from "@/lib/astro";
import { type ForumHome, ago, memberHref } from "@/lib/forum";
import { type ForumHome, type ThreadCard, ago, memberHref } from "@/lib/forum";
import { forumGet } from "@/lib/forumServer";
import { loadSky } from "@/lib/sky";
import { MOON_IN_SIGN, SIGN_IN, withArticle } from "@/lib/skyText";
@@ -61,10 +61,16 @@ function SkyCard({ sky }: { sky: SkyNow }) {
);
}
export default async function ForumHomePage() {
const [home, sky] = await Promise.all([forumGet<ForumHome>("/v1/forum/home"), loadSky()]);
export default async function ForumHomePage({ searchParams }: { searchParams: Promise<{ oldal?: string }> }) {
const page = Math.max(1, Number((await searchParams).oldal) || 1);
const [home, sky, latest] = await Promise.all([
forumGet<ForumHome>("/v1/forum/home"),
loadSky(),
forumGet<{ threads: ThreadCard[]; has_more: boolean }>(`/v1/forum/latest?page=${page}`),
]);
if (!home.ok) notFound();
const { viewer, replies, waiting, topics, unanswered, hot } = home.data;
const pinned = home.data.pinned ?? [];
return (
<div className="fh fh-home">
@@ -135,6 +141,17 @@ export default async function ForumHomePage() {
</section>
)}
{pinned.length > 0 && (
<section className="fh-section o-6" aria-labelledby="fh-pinned">
<div className="fh-section-head">
<h2 id="fh-pinned">Kitűzve</h2>
</div>
<div className="fh-card fh-flush">
<ThreadList threads={pinned} />
</div>
</section>
)}
<section className="fh-section o-6" aria-labelledby="fh-topics">
<div className="fh-section-head">
<h2 id="fh-topics">Témák</h2>
@@ -234,6 +251,25 @@ export default async function ForumHomePage() {
</details>
)}
</section>
{latest.ok && (latest.data.threads.length > 0 || page > 1) && (
<section className="fh-section o-6" id="legutobbi" aria-labelledby="fh-latest">
<div className="fh-section-head">
<h2 id="fh-latest">Legutóbbi szálak</h2>
<span className="hint">a legfrissebb beszélgetések elöl</span>
</div>
<div className="fh-card fh-flush">
<ThreadList threads={latest.data.threads} />
</div>
{(page > 1 || latest.data.has_more) && (
<nav className="forum-pager" aria-label="Lapozás">
{page > 1 ? <Link href={`/forum?oldal=${page - 1}#legutobbi`}>‹ Újabbak</Link> : <span />}
<span className="hint">{page}. oldal</span>
{latest.data.has_more ? <Link href={`/forum?oldal=${page + 1}#legutobbi`}>Régebbiek ›</Link> : <span />}
</nav>
)}
</section>
)}
</div>
<aside className="fh-col fh-col-side" aria-label="Oldalsáv">
@@ -3,6 +3,7 @@ import Link from "next/link";
import { INTENTS, type ThreadCard, ago, threadHref } from "@/lib/forum";
import { Avatar } from "./Avatar";
import { TopicIcon } from "./TopicIcon";
export function IntentTag({ intent, long = false }: { intent: ThreadCard["intent"]; long?: boolean }) {
if (!intent) return null;
@@ -10,53 +11,80 @@ export function IntentTag({ intent, long = false }: { intent: ThreadCard["intent
return <span className={`ft-intent ft-intent-${intent}`}>{text}</span>;
}
function UnreadPill({ n }: { n: number | null }) {
function UnreadPill({ n, onlyNew = false }: { n: number | null; onlyNew?: boolean }) {
if (n === null) return null;
if (n === 0) return <span className="ft-read">olvasva</span>;
if (n === 0) return onlyNew ? null : <span className="ft-read">olvasva</span>;
return <span className="ft-new">{n > 99 ? "99+" : n} új</span>;
}
/** Threads in a list: title, topic, replies, the starter, what is new. */
/**
* Threads in a list. Each card: the topic (with a lock for members-only and
* restricted ones), pinned and the wish, the title, the start of the opening
* post (two lines on a computer, three on a phone), the starter; replies,
* the last activity and what is new on the right on a computer, in the
* bottom line on a phone.
*/
export function ThreadList({ threads, showTopic = true }: { threads: ThreadCard[]; showTopic?: boolean }) {
return (
<ul className="ft-list">
{threads.map((t) => (
<li key={t.id}>
<Link href={threadHref(t)} className="ft-row">
<span className="ft-main">
<span className="ft-title">
{t.pinned && <span className="ft-pin">Kitűzve</span>}
{t.locked && <span className="ft-pin">Lezárva</span>}
{t.title}
</span>
<span className="ft-meta">
{t.author && <Avatar avatar={t.author.avatar} size={20} online={t.author.online} />}
<span>
{t.system ? "Sorsfonalak" : (t.author?.nickname ?? "Törölt tag")}
{showTopic && ` · ${t.topic.name}`}
{threads.map((t) => {
const closed = t.topic.visibility !== undefined && t.topic.visibility !== "public";
const tags = showTopic || t.pinned || t.locked || t.intent;
return (
<li key={t.id}>
<Link href={threadHref(t)} className="ft-row">
<span className="ft-main">
{tags && (
<span className="ft-tags">
{showTopic && (
<span className="ft-topic">
<TopicIcon slug={t.topic.slug} />
{t.topic.name}
{closed && (
<svg viewBox="0 0 24 24" className="ft-lock" role="img" aria-label="Nem nyilvános téma">
<rect x="5" y="11" width="14" height="9" rx="2" />
<path d="M8 11V8a4 4 0 0 1 8 0v3" />
</svg>
)}
</span>
)}
{t.pinned && <span className="ft-pin">Kitűzve</span>}
{t.locked && <span className="ft-pin">Lezárva</span>}
<IntentTag intent={t.intent} />
</span>
)}
<span className="ft-title">{t.title}</span>
{t.excerpt && <span className="ft-excerpt">{t.excerpt}</span>}
<span className="ft-meta">
{t.author && <Avatar avatar={t.author.avatar} size={20} online={t.author.online} />}
<span className="ft-who">{t.system ? "Sorsfonalak" : (t.author?.nickname ?? "Törölt tag")}</span>
<span className="ft-m-narrow">
{" "}
· {t.reply_count} válasz ·{" "}
<time suppressHydrationWarning dateTime={t.last_post_at}>
{ago(t.last_post_at)}
</time>
</span>
<span className="ft-m-narrow ft-m-new">
<UnreadPill n={t.unread} onlyNew />
</span>
</span>
</span>
</span>
<span className="ft-col ft-col-replies">
<strong>{t.reply_count}</strong> válasz
{t.participants > 1 && <span className="hint">{t.participants} résztvevő</span>}
</span>
<span className="ft-col ft-col-last">
<time suppressHydrationWarning dateTime={t.last_post_at}>
{ago(t.last_post_at)}
</time>
</span>
<UnreadPill n={t.unread} />
</Link>
</li>
))}
<span className="ft-side">
<span>
<strong>{t.reply_count}</strong> válasz
</span>
<span className="hint">
utoljára{" "}
<time suppressHydrationWarning dateTime={t.last_post_at}>
{ago(t.last_post_at)}
</time>
</span>
<UnreadPill n={t.unread} />
</span>
</Link>
</li>
);
})}
</ul>
);
}
+5 -1
View File
@@ -61,8 +61,10 @@ export interface ThreadCard {
slug: string;
title: string;
intent: "listen" | "advice" | null;
topic: TopicRef;
topic: TopicRef & { visibility?: string };
author: ForumAuthor | null;
/** The start of the opening post (as much as a card shows). */
excerpt?: string | null;
created_at: string;
last_post_at: string;
reply_count: number;
@@ -86,6 +88,8 @@ export interface ForumHome {
topics: ForumTopic[];
unanswered: ThreadCard[];
hot: ThreadCard[];
/** Pinned threads, above the topics. */
pinned?: ThreadCard[];
}
export interface TopicPage {