Files
sorsfonalak/services/frontend/src/app/s/[slug]/page.tsx
T
fecoandClaude Opus 5.5 1ab693175e
CI / test (push) Successful in 1m22s
CI / build (push) Successful in 4m46s
CI / deploy (push) Skipped
The visitor header on every public page
The example analysis, shared charts, the invitation page and the privacy
page showed visitors just the logo. They now get the home page's header:
the sections, the example and the login.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
2026-11-19 11:42:02 +00:00

109 lines
4.4 KiB
TypeScript

import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import { ChartWheel, WheelLegend } from "@/components/ChartWheel";
import { Rich } from "@/components/Rich";
import { ShareVisit } from "@/components/ShareVisit";
import { PublicHeader } from "@/components/SiteHeader";
import { SIGNS, signName } from "@/lib/astro";
import { getMe } from "@/lib/server";
import { bigThree, imageVersion, loadShare, plain, shorten, siteUrl } from "@/lib/share";
type Props = { params: Promise<{ slug: string }> };
/** Title, description and preview image for Facebook, Messenger, WhatsApp and co. */
export async function generateMetadata({ params }: Props): Promise<Metadata> {
const { slug } = await params;
const share = await loadShare(slug);
if (!share?.chart) return { title: "A link nem érhető el", robots: { index: false } };
const base = await siteUrl();
const title = share.summary?.title ?? "Születési képlet";
const description = share.summary?.summary
? shorten(plain(share.summary.summary), 200)
: "Egy születési képlet a Sorsfonalakon.";
const url = `${base}/s/${slug}`;
const image = { url: `${base}/s/${slug}/kep/${imageVersion(share)}.png`, width: 1200, height: 630, alt: title };
return {
title,
description,
// Personal content: shown when shared, not listed in search engines.
robots: { index: false, follow: false },
alternates: { canonical: url },
openGraph: { type: "website", siteName: "Sorsfonalak", locale: "hu_HU", url, title, description, images: [image] },
twitter: { card: "summary_large_image", title, description, images: [image.url] },
};
}
/** A shared chart: the wheel and its short summary, open to anyone with the link. */
export default async function SharedChartPage({ params }: Props) {
const { slug } = await params;
const [share, me] = await Promise.all([loadShare(slug), getMe()]);
const chart = share?.chart?.chart;
if (!share || !chart) notFound();
const summary = share.summary;
const trio = bigThree(chart);
return (
<>
<ShareVisit slug={slug} />
{!me && (
<PublicHeader />
)}
<main className="page" style={{ maxWidth: 1180 }}>
<div className="page-head">
<span className="eyebrow">Megosztott születési képlet</span>
<h1>{summary?.title ?? "Születési képlet"}</h1>
</div>
<section className="chart-layout" aria-label="A megosztott képlet">
<div className="card chart-wheel-card">
<ChartWheel chart={chart} timeKnown={chart.time_known} />
<WheelLegend />
</div>
<div className="field chart-side">
<section className="card summary-card" aria-label="Röviden">
<span className="eyebrow">Röviden</span>
{summary?.summary ? (
<p className="summary-text" lang={summary.language}>
<Rich text={summary.summary} />
</p>
) : (
<p className="muted">Ehhez a képlethez még nincs rövid összefoglaló.</p>
)}
{trio.length > 0 && (
<p className="share-trio">
{trio.map((t) => (
<span key={t.label}>
<span className="sym" aria-hidden="true">
{SIGNS[t.sign]?.glyph}
</span>{" "}
{t.label} {signName(t.sign)}
</span>
))}
</p>
)}
{!chart.time_known && (
<p className="hint">A születési idő nem ismert, ezért a képleten nincsenek házak és Aszcendens.</p>
)}
</section>
<section className="card share-cta">
<h2>És a te képleted mit mutat?</h2>
<p className="muted">
Add meg a születési adataidat, és megkapod a saját képletedet a rövid összefoglalóval együtt, ingyen.
</p>
<Link href={me ? "/keplet" : "/belepes"} className="btn btn-primary">
{me ? "A saját képletem" : "Elkészítem a sajátomat"}
</Link>
</section>
</div>
</section>
<p className="hint">
Ezt a képletet a tulajdonosa osztotta meg, név és születési adatok nélkül. A szöveget mesterséges intelligencia
írta a képlet alapján.
</p>
</main>
</>
);
}