docs: add SEO implementation documentation and tests
- Add comprehensive SEO implementation guide - Add automated SEO testing script - Document all schema types and integrations - Include verification methods and expected impact
This commit is contained in:
95
scripts/test-seo.js
Normal file
95
scripts/test-seo.js
Normal file
@@ -0,0 +1,95 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* SEO Best Practices Test
|
||||
* Verifies schema markup and meta tags are properly generated
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
console.log('🔍 Testing SEO Implementation...\n');
|
||||
|
||||
const results = {
|
||||
passed: 0,
|
||||
failed: 0,
|
||||
warnings: 0,
|
||||
tests: []
|
||||
};
|
||||
|
||||
function test(name, condition, critical = true) {
|
||||
const status = condition ? '✅ PASS' : critical ? '❌ FAIL' : '⚠️ WARN';
|
||||
results.tests.push({ name, status, critical });
|
||||
|
||||
if (condition) {
|
||||
results.passed++;
|
||||
} else if (critical) {
|
||||
results.failed++;
|
||||
} else {
|
||||
results.warnings++;
|
||||
}
|
||||
|
||||
console.log(`${status}: ${name}`);
|
||||
}
|
||||
|
||||
// Test 1: Check if SEO modules exist
|
||||
console.log('📦 Module Structure Tests:');
|
||||
test('Keywords module exists', fs.existsSync('src/lib/seo/keywords/index.ts'));
|
||||
test('Schema module exists', fs.existsSync('src/lib/seo/schema/index.ts'));
|
||||
test('SEO components exist', fs.existsSync('src/components/seo/index.ts'));
|
||||
|
||||
// Test 2: Check if all locale configs exist
|
||||
console.log('\n🌍 Locale Configuration Tests:');
|
||||
const locales = ['sr', 'en', 'de', 'fr'];
|
||||
locales.forEach(locale => {
|
||||
test(`Keywords config for ${locale}`,
|
||||
fs.existsSync(`src/lib/seo/keywords/locales/${locale}.ts`));
|
||||
});
|
||||
|
||||
// Test 3: Check schema generators
|
||||
console.log('\n🏗️ Schema Generator Tests:');
|
||||
test('Product schema generator exists',
|
||||
fs.existsSync('src/lib/seo/schema/productSchema.ts'));
|
||||
test('Organization schema generator exists',
|
||||
fs.existsSync('src/lib/seo/schema/organizationSchema.ts'));
|
||||
test('Breadcrumb schema generator exists',
|
||||
fs.existsSync('src/lib/seo/schema/breadcrumbSchema.ts'));
|
||||
|
||||
// Test 4: Check React components
|
||||
console.log('\n⚛️ React Component Tests:');
|
||||
test('JsonLd component exists',
|
||||
fs.existsSync('src/components/seo/JsonLd.tsx'));
|
||||
test('ProductSchema component exists',
|
||||
fs.existsSync('src/components/seo/ProductSchema.tsx'));
|
||||
test('OrganizationSchema component exists',
|
||||
fs.existsSync('src/components/seo/OrganizationSchema.tsx'));
|
||||
|
||||
// Test 5: Check page integrations
|
||||
console.log('\n📄 Page Integration Tests:');
|
||||
test('Root layout updated with OrganizationSchema',
|
||||
fs.readFileSync('src/app/layout.tsx', 'utf8').includes('OrganizationSchema'));
|
||||
test('Product page has ProductSchema',
|
||||
fs.readFileSync('src/app/[locale]/products/[slug]/page.tsx', 'utf8').includes('ProductSchema'));
|
||||
test('Product page has enhanced metadata',
|
||||
fs.readFileSync('src/app/[locale]/products/[slug]/page.tsx', 'utf8').includes('openGraph'));
|
||||
test('Checkout has noindex layout',
|
||||
fs.existsSync('src/app/[locale]/checkout/layout.tsx'));
|
||||
|
||||
// Test 6: Check TypeScript types
|
||||
console.log('\n📐 TypeScript Type Tests:');
|
||||
test('SEO types defined', fs.existsSync('src/lib/seo/keywords/types.ts'));
|
||||
test('Schema types defined', fs.existsSync('src/lib/seo/schema/types.ts'));
|
||||
|
||||
// Summary
|
||||
console.log('\n' + '='.repeat(50));
|
||||
console.log(`✅ Passed: ${results.passed}`);
|
||||
console.log(`❌ Failed: ${results.failed}`);
|
||||
console.log(`⚠️ Warnings: ${results.warnings}`);
|
||||
console.log('='.repeat(50));
|
||||
|
||||
if (results.failed === 0) {
|
||||
console.log('\n🎉 All critical SEO tests passed!');
|
||||
process.exit(0);
|
||||
} else {
|
||||
console.log(`\n⚠️ ${results.failed} critical test(s) failed.`);
|
||||
process.exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user