Share reward and less robot load on shared links
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
This commit is contained in:
@@ -27,10 +27,19 @@ export interface PublicShare {
|
||||
|
||||
const SLUG = /^[A-Za-z0-9_-]{8,64}$/;
|
||||
|
||||
/** The shared content, or `null` if the link is unknown or revoked (one backend call per request). */
|
||||
/** Cache tag of the shared content; revoking a link clears it (see the /api/v1 proxy). */
|
||||
export const SHARES_TAG = "shares";
|
||||
|
||||
/**
|
||||
* The shared content, or `null` if the link is unknown or revoked. Kept for
|
||||
* five minutes, so robots opening the page again and again do not reach the
|
||||
* backend; one backend call per request at most.
|
||||
*/
|
||||
export const loadShare = cache(async (slug: string): Promise<PublicShare | null> => {
|
||||
if (!SLUG.test(slug)) return null;
|
||||
const res = await fetch(`${BACKEND_URL}/v1/public/shares/${slug}`, { cache: "no-store" });
|
||||
const res = await fetch(`${BACKEND_URL}/v1/public/shares/${slug}`, {
|
||||
next: { revalidate: 300, tags: [SHARES_TAG] },
|
||||
});
|
||||
if (res.status === 404) return null;
|
||||
if (!res.ok) throw new Error(`share ${slug}: HTTP ${res.status}`);
|
||||
return (await res.json()) as PublicShare;
|
||||
|
||||
Reference in New Issue
Block a user