#!/usr/bin/env node /** * Generate Open Graph images for Miracles In Motion * This script creates social media preview images */ import fs from 'fs' import path from 'path' const OG_CONFIG = { width: 1200, height: 630, title: 'Miracles In Motion', subtitle: 'Essentials for Every Student', description: '501(c)3 Non-Profit Organization' } /** * Create SVG template for OG image */ function createOGImageSVG(config = OG_CONFIG) { return ` ${config.title} ${config.subtitle} ${config.description} Learn More miraclesinmotion.org `.trim() } /** * Generate OG images */ function generateOGImages() { const publicDir = path.join(process.cwd(), 'public') // Ensure public directory exists if (!fs.existsSync(publicDir)) { fs.mkdirSync(publicDir, { recursive: true }) } // Create default OG image const defaultOG = createOGImageSVG() fs.writeFileSync(path.join(publicDir, 'og-image.svg'), defaultOG) console.log('āœ… Generated og-image.svg') // Create page-specific OG images const pages = [ { name: 'donate', title: 'Donate', subtitle: 'Help Students Succeed' }, { name: 'volunteer', title: 'Volunteer', subtitle: 'Make a Difference' }, { name: 'stories', title: 'Stories', subtitle: 'Impact in Action' }, ] pages.forEach(page => { const pageOG = createOGImageSVG({ ...OG_CONFIG, title: page.title, subtitle: page.subtitle }) fs.writeFileSync(path.join(publicDir, `og-image-${page.name}.svg`), pageOG) console.log(`āœ… Generated og-image-${page.name}.svg`) }) console.log('\nšŸŽ‰ All OG images generated successfully!') console.log('\nNote: These are SVG files. For production, consider converting to PNG using a tool like:') console.log('- Puppeteer for programmatic conversion') console.log('- Online converters') console.log('- Design tools like Figma or Canva') } // Run if called directly if (import.meta.url === `file://${process.argv[1]}`) { try { generateOGImages() } catch (error) { console.error('āŒ Error generating OG images:', error) process.exit(1) } } export { generateOGImages, createOGImageSVG }