neuer versuch
This commit is contained in:
80
scripts/submit-indexnow.ts
Normal file
80
scripts/submit-indexnow.ts
Normal file
@@ -0,0 +1,80 @@
|
||||
|
||||
import { blogPostList } from '../src/lib/blog-data';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
const HOST = 'www.qrmaster.net';
|
||||
const KEY = '1234567890abcdef';
|
||||
const KEY_LOCATION = `https://${HOST}/${KEY}.txt`;
|
||||
const INDEXNOW_ENDPOINT = 'https://api.indexnow.org/indexnow';
|
||||
|
||||
async function submitIndexNow() {
|
||||
console.log('🚀 Starting IndexNow submission...');
|
||||
|
||||
// 1. Gather all URLs
|
||||
const baseUrl = `https://${HOST}`;
|
||||
const staticPages = [
|
||||
'',
|
||||
'/pricing',
|
||||
'/faq',
|
||||
'/blog',
|
||||
'/signup',
|
||||
'/login',
|
||||
'/privacy',
|
||||
'/qr-code-erstellen',
|
||||
'/qr-code-tracking',
|
||||
'/dynamic-qr-code-generator',
|
||||
'/bulk-qr-code-generator',
|
||||
'/newsletter',
|
||||
];
|
||||
|
||||
// Dynamically get tool slugs from directory
|
||||
const toolsDir = path.join(process.cwd(), 'src/app/(marketing)/tools');
|
||||
let freeTools: string[] = [];
|
||||
|
||||
try {
|
||||
freeTools = fs.readdirSync(toolsDir).filter(file => {
|
||||
return fs.statSync(path.join(toolsDir, file)).isDirectory();
|
||||
});
|
||||
} catch (e) {
|
||||
console.warn('⚠️ Could not read tools directory:', e);
|
||||
}
|
||||
|
||||
const toolTypeUrls = freeTools.map(slug => `/tools/${slug}`);
|
||||
const blogUrls = blogPostList.map(post => `/blog/${post.slug}`);
|
||||
|
||||
const allPaths = [...staticPages, ...toolTypeUrls, ...blogUrls];
|
||||
const urlList = allPaths.map(path => `${baseUrl}${path}`);
|
||||
|
||||
console.log(`📝 Found ${urlList.length} URLs to submit.`);
|
||||
|
||||
// 2. Prepare payload
|
||||
const payload = {
|
||||
host: HOST,
|
||||
key: KEY,
|
||||
keyLocation: KEY_LOCATION,
|
||||
urlList: urlList,
|
||||
};
|
||||
|
||||
try {
|
||||
// 3. Send Request
|
||||
const response = await fetch(INDEXNOW_ENDPOINT, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
|
||||
if (response.status === 200 || response.status === 202) {
|
||||
console.log('✅ IndexNow submission successful!');
|
||||
} else {
|
||||
console.error(`❌ IndexNow submission failed. Status: ${response.status}`);
|
||||
console.error(await response.text());
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('❌ Error submitting to IndexNow:', error);
|
||||
}
|
||||
}
|
||||
|
||||
submitIndexNow();
|
||||
Reference in New Issue
Block a user