import Link from "next/link"; import { POINTS, SIGNS } from "@/lib/astro"; import { type ForumAuthor, ago, memberHref } from "@/lib/forum"; import { Avatar } from "./Avatar"; import { Badge, RankBadge } from "./Badges"; /** "☉ Halak · ☽ Rák · Asz Szűz": the signs a member chose to share. */ export function signsText(signs: Record | null | undefined): string | null { if (!signs) return null; const parts = Object.entries(signs) .sort(([a], [b]) => order(a) - order(b)) .map(([point, sign]) => { const name = SIGNS[sign]?.hu ?? sign; return point === "ascendant" ? `Asz ${name}` : `${POINTS[point]?.glyph ?? point} ${name}`; }); return parts.length ? parts.join(" · ") : null; } /** * The short form next to a post: Sun, Moon and Ascendant as glyphs * ("☉♓ ☽♋ ↑♍"), with the names in `title`. Every planet only on the profile. */ export function signGlyphs(signs: Record | null | undefined): { text: string; title: string } | null { if (!signs) return null; const parts: string[] = []; const names: string[] = []; for (const [point, label] of [ ["sun", "Nap"], ["moon", "Hold"], ["ascendant", "Aszcendens"], ] as const) { const sign = signs[point]; if (!sign) continue; const mark = point === "ascendant" ? "↑" : (POINTS[point]?.glyph ?? ""); parts.push(`${mark}${SIGNS[sign]?.glyph ?? ""}`); names.push(`${label}: ${SIGNS[sign]?.hu ?? sign}`); } return parts.length ? { text: parts.join(" "), title: names.join(", ") } : null; } const ORDER = [ "sun", "moon", "ascendant", "mercury", "venus", "mars", "jupiter", "saturn", "uranus", "neptune", "pluto", ]; function order(point: string) { const i = ORDER.indexOf(point); return i < 0 ? 99 : i; } /** * Who wrote it: avatar with the online dot, nickname, rank, badges, the * shared signs and the time. A deleted account shows as "Törölt tag". */ export function AuthorLine({ author, size = 40, time, edited = false, badges, signs = true, }: { author: ForumAuthor | null; size?: number; time?: string; edited?: boolean; badges?: React.ReactNode; signs?: boolean; }) { if (!author) { return (
Törölt tag {time && {ago(time)}}
); } const glyphs = signs ? signGlyphs(author.signs) : null; const shown = glyphs?.text ?? null; return (
{author.nickname} {author.online && (online)} {author.moderator && } {author.founder && } {author.listener && } {author.supporter && } {badges} {(shown || time) && ( {shown && ( {shown} )} {shown && time && " · "} {time && ( )} {edited && " · szerkesztve"} )}
); }