The first visit of a shared link by someone else earns the sharer one free natal analysis, once per user. The share page reports visits from the visitor's browser; robots, the logged-in sharer and the address the link was made at do not count. The share button is a proper card that says so in small print; /v1/me tells whether the reward is used up. Robots: reading a share writes nothing (view_count counts people only), the frontend keeps shared content for five minutes (cleared when a link is revoked), and robots.txt turns away the known AI crawlers while leaving the link preview robots alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
115 lines
4.6 KiB
TypeScript
115 lines
4.6 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 { Logo } 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 && (
|
|
<header className="site-header">
|
|
<Logo />
|
|
<span style={{ flex: 1 }} />
|
|
<Link href="/belepes" className="btn btn-sm">
|
|
Belépés
|
|
</Link>
|
|
</header>
|
|
)}
|
|
<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>
|
|
</>
|
|
);
|
|
}
|