Something went wrong. Try again.
Monorepo for Tangled forked from tangled.org/core
Something went wrong. Try again.
1234567891011121314151617181920212223242526import type { Public } from "#lib/api/public.ts";import { rkeyFromUri } from "#lib/api/uri.ts";
/** * Client-side helper for IndexNow pings via the internal proxy. * Guarantees fire-and-forget: errors are caught silently so user flows are never blocked. */export const pingIndexNow = (urls: string | string[]): void => { const list = Array.isArray(urls) ? urls : [urls]; if (typeof window === "undefined" || list.length === 0) return;
void fetch("/_internal/indexnow", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ urls: list }) }).catch(() => { // silent fire-and-forget });};
export const pingTicketIndexNow = (ticket: Public<{ uri: string }>): void => { if (typeof window === "undefined") return; const path = window.location.pathname.replace(/\/new\/?$/, `/${rkeyFromUri(ticket.uri)}`); pingIndexNow(`https://tangled.org${path}`);};