~james/core

core/web/src/lib/api/indexnow.ts -rw-r--r-- 545 bytes
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 15 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/**
 * 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
	});
};