feat: Introduce Google Indexing API and IndexNow submission scripts with a unified URL gathering utility and setup guide.

This commit is contained in:
Timo Knuth
2026-01-21 13:57:58 +01:00
parent c1471830f3
commit cca1374c9e
6 changed files with 179 additions and 73 deletions

View File

@@ -1,21 +1,23 @@
// Helper script to run IndexNow submission
// Run with: npx tsx scripts/submit-indexnow.ts
// Run with: npm run submit:indexnow
import { getAllIndexableUrls, submitToIndexNow } from '../src/lib/indexnow';
async function main() {
console.log('Gathering URLs for IndexNow submission...');
console.log('🚀 Starting IndexNow Submission Script...');
console.log(' Gathering URLs for IndexNow submission...');
const urls = getAllIndexableUrls();
console.log(`Found ${urls.length} indexable URLs.`);
console.log(` Found ${urls.length} indexable URLs.`);
// Basic validation of key presence (logic can be improved)
if (!process.env.INDEXNOW_KEY) {
console.warn('⚠️ WARNING: INDEXNOW_KEY environment variable is not set. Using placeholder.');
// In production, you'd fail here. For dev/demo, we proceed but expect failure from API.
console.warn('⚠️ WARNING: INDEXNOW_KEY environment variable is not set.');
console.warn(' The submission might fail if the key is not hardcoded in src/lib/indexnow.ts');
}
await submitToIndexNow(urls);
console.log('\n✨ IndexNow submission process completed.');
}
main().catch(console.error);