Files
mintel.me/scripts/test-embeds.ts
2026-01-14 17:15:10 +01:00

77 lines
2.2 KiB
TypeScript

#!/usr/bin/env tsx
/**
* Test script to verify embed components are properly structured
*/
import { existsSync } from 'fs';
import { join } from 'path';
const componentsDir = join(process.cwd(), 'src', 'components');
const embedsDir = join(componentsDir, 'Embeds');
const requiredFiles = [
'YouTubeEmbed.astro',
'TwitterEmbed.astro',
'GenericEmbed.astro',
'Embeds/index.ts'
];
const optionalFiles = [
'embedDemoPost.ts'
];
console.log('🔍 Testing Embed Components...\n');
let allPassed = true;
// Check component files exist
requiredFiles.forEach(file => {
const filePath = join(process.cwd(), 'src', 'components', file.replace('Embeds/', ''));
const exists = existsSync(filePath);
if (exists) {
console.log(`${file}`);
} else {
console.log(`${file} - MISSING`);
allPassed = false;
}
});
// Check optional files
optionalFiles.forEach(file => {
const filePath = join(process.cwd(), 'src', 'data', file);
const exists = existsSync(filePath);
if (exists) {
console.log(`${file} (optional)`);
} else {
console.log(`⚠️ ${file} - not found (optional)`);
}
});
// Check embeds directory
if (existsSync(embedsDir)) {
console.log(`✅ Embeds directory exists`);
} else {
console.log(`❌ Embeds directory - MISSING`);
allPassed = false;
}
console.log('\n📋 Component Summary:');
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
console.log('YouTubeEmbed - Build-time YouTube embeds with full styling control');
console.log('TwitterEmbed - Build-time Twitter embeds with oEmbed API');
console.log('GenericEmbed - Universal oEmbed support for any provider');
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
if (allPassed) {
console.log('\n🎉 All required components are in place!');
console.log('\nNext steps:');
console.log('1. Add embeds to your blog posts');
console.log('2. Customize styling with CSS variables');
console.log('3. Check EMBED_USAGE_GUIDE.md for examples');
process.exit(0);
} else {
console.log('\n❌ Some components are missing. Please check the files above.');
process.exit(1);
}