chore(indexnow): varsayılan kuru çalıştırma, --gonder ile gönderim; çıplak slug kabulü
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,9 +7,14 @@
|
||||
* public/ altındaki dosya da birlikte değişmeli.
|
||||
*
|
||||
* Kullanım (canlıda 200 dönen adresler için, yayından SONRA):
|
||||
* pnpm indexnow https://kolaytercih.com/rehber/<slug> [...]
|
||||
* pnpm indexnow --rehber # content/rehber altındaki tüm yazılar
|
||||
* pnpm indexnow --sitemap # canlı sitemap.xml'deki tüm adresler (10.000'e kadar)
|
||||
* pnpm indexnow <slug> [...] # rehber yazısı: /rehber/<slug>
|
||||
* pnpm indexnow https://kolaytercih.com/<yol> [...]
|
||||
* pnpm indexnow --rehber # content/rehber altındaki tüm yazılar
|
||||
* pnpm indexnow --sitemap # canlı sitemap.xml'deki tüm adresler (10.000'e kadar)
|
||||
*
|
||||
* Varsayılan KURU ÇALIŞTIRMADIR: gönderilecek gövde yazdırılır, IndexNow'a
|
||||
* istek gitmez. Gerçek bildirim için `--gonder` eklenir:
|
||||
* pnpm indexnow <slug> --gonder
|
||||
*
|
||||
* Bing Webmaster → IndexNow sekmesinde alınan bildirimler görünür; Yandex
|
||||
* Webmaster'da "Indexing → IndexNow" altında. Aynı adres günde bir kez yeter.
|
||||
@@ -53,14 +58,24 @@ async function sitemapAdresleri(): Promise<string[]> {
|
||||
|
||||
async function main() {
|
||||
const args = process.argv.slice(2);
|
||||
const gonder = args.includes("--gonder");
|
||||
let adresler: string[];
|
||||
if (args.includes("--rehber")) adresler = rehberAdresleri();
|
||||
else if (args.includes("--sitemap")) adresler = await sitemapAdresleri();
|
||||
else adresler = args.filter((a) => a.startsWith("http"));
|
||||
else {
|
||||
// Tam adres olduğu gibi; çıplak slug rehber yazısının adresine çevrilir.
|
||||
adresler = args
|
||||
.filter((a) => !a.startsWith("--"))
|
||||
.map((a) =>
|
||||
a.startsWith("http") ? a : `${SITE}/rehber/${a.replace(/^\/+|\/+$/g, "")}`,
|
||||
);
|
||||
}
|
||||
|
||||
adresler = [...new Set(adresler)].filter((a) => a.startsWith(SITE));
|
||||
if (adresler.length === 0) {
|
||||
console.error("indexnow: adres yok. Kullanım: pnpm indexnow <url...> | --rehber | --sitemap");
|
||||
console.error(
|
||||
"indexnow: adres yok. Kullanım: pnpm indexnow <slug|url...> | --rehber | --sitemap [--gonder]",
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
if (adresler.length > 10_000) {
|
||||
@@ -68,15 +83,23 @@ async function main() {
|
||||
}
|
||||
|
||||
const key = anahtarOku();
|
||||
const govde = {
|
||||
host: HOST,
|
||||
key,
|
||||
keyLocation: `${SITE}/${key}.txt`,
|
||||
urlList: adresler,
|
||||
};
|
||||
if (!gonder) {
|
||||
console.log(`indexnow: KURU ÇALIŞTIRMA — ${adresler.length} adres, istek gönderilmedi.`);
|
||||
console.log(`POST ${UC}`);
|
||||
console.log(JSON.stringify(govde, null, 2));
|
||||
console.log("Göndermek için aynı komutu --gonder ile çalıştır.");
|
||||
return;
|
||||
}
|
||||
const res = await fetch(UC, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json; charset=utf-8" },
|
||||
body: JSON.stringify({
|
||||
host: HOST,
|
||||
key,
|
||||
keyLocation: `${SITE}/${key}.txt`,
|
||||
urlList: adresler,
|
||||
}),
|
||||
body: JSON.stringify(govde),
|
||||
});
|
||||
// 200 = işlendi, 202 = alındı (anahtar sonra doğrulanacak), 4xx = hata.
|
||||
console.log(`indexnow: ${adresler.length} adres → HTTP ${res.status}`);
|
||||
|
||||
Reference in New Issue
Block a user